name: Build

on: push

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v1

      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: Pull config
        run: git submodule update --init --recursive

      - name: Run tests with Gradle
        shell: cmd
        run: gradlew.bat build

      - name: Run smoke tests with Gradle
        shell: cmd
        run: cd tests & gradlew.bat build --stacktrace

  publish:
    runs-on: ubuntu-latest
    needs: build
    if: github.ref == 'refs/heads/master'

    steps:
      - uses: actions/checkout@v1

      - uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - run: git submodule update --init --recursive

      - name: Decrypt CloudRepo credentials
        run: ./config/scripts/decrypt.sh "$CLOUDREPO_CREDENTIALS_KEY" ./cloudrepo.properties.gpg ./cloudrepo.properties
        env:
          CLOUDREPO_CREDENTIALS_KEY: ${{ secrets.CLOUDREPO_CREDENTIALS_KEY }}

      - name: Publish artifacts to Maven
        run: ./gradlew assemble publish --stacktrace
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

name: Build

on: push

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v1

      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: Pull config
        run: git submodule update --init --recursive

      - name: Run tests with Gradle
        shell: cmd
        run: gradlew.bat build

      - name: Run smoke tests with Gradle
        shell: cmd
        run: cd tests & gradlew.bat build --stacktrace

  publish:
    runs-on: ubuntu-latest
    needs: build
    if: github.ref == 'refs/heads/master'

    steps:
      - uses: actions/checkout@v1

      - uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - run: git submodule update --init --recursive

      - name: Decrypt CloudRepo credentials
        run: ./config/scripts/decrypt.sh "$CLOUDREPO_CREDENTIALS_KEY" ./cloudrepo.properties.gpg ./cloudrepo.properties
        env:
          CLOUDREPO_CREDENTIALS_KEY: ${{ secrets.CLOUDREPO_CREDENTIALS_KEY }}

      - name: Decrypt Git SSH credentials
        run: ./config/scripts/decrypt.sh "GIT_CREDENTIALS_KEY" ./deploy_key_rsa.gpg ./deploy_key_rsa
        env:
          GIT_CREDENTIALS_KEY: ${{ secrets.GIT_CREDENTIALS_KEY }}

      - name: Decrypt GCS credentials
        run: ./config/scripts/decrypt.sh "GCS_CREDENTIALS_KEY" ./gcs-auth-key.json.gpg ./gcs-auth-key.json
        env:
          GCS_CREDENTIALS_KEY: ${{ secrets.GCS_CREDENTIALS_KEY }}

      - name: Publish artifacts to Maven
        run: ./gradlew assemble publish --stacktrace
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Decrypt all credentials when publishing artifacts
Decrypt all credentials when publishing artifacts
