name: Build Chain

on: [pull_request]

jobs:
  build-chain:
    strategy:
      matrix:
        java-version: [8, 11]
      fail-fast: false
    runs-on: ubuntu-18.04
    name: Maven Build
    steps:
      - name: Free disk space
        shell: bash
        run: |
          sudo rm -rf /usr/share/dotnet
          sudo rm -rf /usr/local/lib/android
          sudo rm -rf /opt/ghc
          docker rmi $(docker image ls -aq)
          df -h
      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java-version }}
      # See https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven#caching-dependencies
      - name: Cache Maven packages
        uses: actions/cache@v2
        with:
          path: ~/.m2
          key: ${{ runner.os }}-${{ matrix.java-version }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-${{ matrix.java-version }}-m2
      - name: Build Chain ${{ matrix.java-version }}
        id: build-chain
        uses: kiegroup/github-action-build-chain@v2.6.2
        with:
          definition-file: https://raw.githubusercontent.com/${GROUP}/droolsjbpm-build-bootstrap/${BRANCH}/.ci/pull-request-config.yaml
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
      - name: Check Surefire Report
        if: ${{ always() }}
        uses: ScaCap/action-surefire-report@v1.0.10
        with:
          fail_on_test_failures: true
          fail_if_no_tests: false
          skip_publishing: true
                            
