name: Build

on:
  pull_request:

jobs:
  build:
    name: Build
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-latest ]
    runs-on: ${{ matrix.os }}
    if: startsWith(github.event.head_commit.message, 'Releasing version') != true

    steps:
      - uses: actions/checkout@v2

      - name: Set up Java
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - uses: actions/cache@v2
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }}
          restore-keys: |
            ${{ runner.os }}-gradle-

      - uses: actions/cache@v2
        with:
          path: ~/.gradle/wrapper
          key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}
          restore-keys: |
            ${{ runner.os }}-gradlew-

      - name: Build
        run: ./gradlew build -S

      - name: Show Reports
        uses: actions/upload-artifact@v1
        if: failure()
        with:
          name: reports-${{ runner.os }}
          path: build/
