diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0233def..db3c9f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: tags-ignore: [ "**" ] pull_request: release: - types: [ released ] + types: [ published ] jobs: build: # Only run on PRs if the source branch is on someone else's repo @@ -19,13 +19,19 @@ jobs: with: distribution: 'temurin' java-version: 17 + - uses: gradle/gradle-build-action@v2 + with: + # allow main and *-dev branches to write caches (default is only main/main) + cache-read-only: ${{ github.ref != 'refs/heads/main' && !(endsWith(github.ref, '-dev') && startsWith(github.ref, 'refs/heads/')) }} - name: Build run: ./gradlew build - - name : Test Summary - uses : EnricoMi/publish-unit-test-result-action@v2.11.0 - with : - junit_files : "**/build/test-results/test/TEST-*.xml" - if : always() + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: Test Results + path: | + **/build/test-results/test/TEST-*.xml - name: Determine Status run: | if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then @@ -34,7 +40,7 @@ jobs: echo "STATUS=release" >> $GITHUB_ENV fi - name: Publish Snapshot - if: "${{ env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}" + if: "${{ env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}" run: ./gradlew publish env: ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" @@ -47,3 +53,14 @@ jobs: ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" ORG_GRADLE_PROJECT_signingKey: "${{ secrets.SIGNING_KEY }}" ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.SIGNING_PASSWORD }}" + event_file: + name: "Event File" + # Only run on PRs if the source branch is on someone else's repo + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} + runs-on: ubuntu-latest + steps: + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: Event File + path: ${{ github.event_path }} diff --git a/.github/workflows/test_results.yml b/.github/workflows/test_results.yml new file mode 100644 index 0000000..97b50d1 --- /dev/null +++ b/.github/workflows/test_results.yml @@ -0,0 +1,33 @@ +name: Test Results + +on: + workflow_run: + workflows: [ "Build cloud-spring" ] + types: + - completed +permissions: { } + +jobs: + test-results: + name: Test Results + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + permissions: + checks: write + # needed unless run with comment_mode: off + pull-requests: write + # required by download step to access artifacts API + actions: read + steps: + - name: Download and Extract Artifacts + uses: dawidd6/action-download-artifact@v3 + with: + run_id: ${{ github.event.workflow_run.id }} + path: artifacts + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + files: "artifacts/**/*.xml"