name: Helix Manual CI
on:
  workflow_dispatch:
    inputs:
      buildRef:
        description: Ref to build (commit, branch, or refs/pull/1234/head or refs/pull/1234/merge)
        required: true
        default: refs/pull/1234/merge
      mvnOpts:
        description: Can provide custom Maven options in addition to existing one.
        required: true
        default: --fail-at-end
      goals:
        description: Can provide custom Maven goals in addition to existing one.
        required: true
        default: -fae test

permissions: write-all

jobs:
  MANUAL_CI:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.inputs.buildRef }}
      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 11
      - name: Delete frontend-maven-plugin dir
        run: rm -rf .m2\repository\com\github\eirslett
      - name: Build with Maven
        run: mvn clean install -Dmaven.test.skip.exec=true -DretryFailedDeploymentCount=5
      - name: Run All Tests
        run: mvn -B -V -e -ntp "-Dstyle.color=always" ${{ github.event.inputs.mvnOpts }} ${{ github.event.inputs.goals }}
      - name: Test Report
        uses: dorny/test-reporter@v1
        if: always()
        with:
          name: Tests Results
          path: './**/target/surefire-reports/TEST-TestSuite.xml'
          reporter: java-junit
      - name: Upload unit test results
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: surefire-reports
          path: ./**/target/surefire-reports/
          if-no-files-found: ignore
