From 402a9b398868bd9bd385210138d6f8ea610c8c40 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Sat, 6 Nov 2021 22:36:49 +0100 Subject: [PATCH] Publish test results from workflow_run only (#5947) --- .github/workflows/ci.yaml | 19 ++++++------------- .github/workflows/publish-test-results.yaml | 17 ++++++----------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e774803dda7..82e21a4f46c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -108,19 +108,12 @@ jobs: name: codecov-umbrella fail_ci_if_error: false - publish-test-results: - needs: test + event_file: + name: "Event File" runs-on: ubuntu-latest - # the build-and-test job might be skipped, we don't need to run this job then - if: success() || failure() - steps: - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - path: test-results - - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 + - name: Upload + uses: actions/upload-artifact@v2 with: - files: test-results/**/*.xml + name: Event File + path: ${{ github.event_path }} diff --git a/.github/workflows/publish-test-results.yaml b/.github/workflows/publish-test-results.yaml index 485383b31b4..77079c89dfc 100644 --- a/.github/workflows/publish-test-results.yaml +++ b/.github/workflows/publish-test-results.yaml @@ -1,4 +1,4 @@ -# Copied from https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.18/README.md#support-fork-repositories-and-dependabot-branches +# Copied from https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.23/README.md#support-fork-repositories-and-dependabot-branches name: Publish test results @@ -12,11 +12,7 @@ jobs: publish-test-results: name: Publish test results runs-on: ubuntu-latest - if: > - github.event.workflow_run.conclusion != 'skipped' && ( - github.event.sender.login == 'dependabot[bot]' || - github.event.workflow_run.head_repository.full_name != github.repository - ) + if: github.event.workflow_run.conclusion != 'skipped' steps: - name: Download and extract artifacts @@ -26,13 +22,10 @@ jobs: mkdir artifacts && cd artifacts artifacts_url=${{ github.event.workflow_run.artifacts_url }} - artifacts=$(gh api $artifacts_url -q '.artifacts[] | {name: .name, url: .archive_download_url}') - IFS=$'\n' - for artifact in $artifacts + gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact do - name=$(jq -r .name <<<$artifact) - url=$(jq -r .url <<<$artifact) + IFS=$'\t' read name url <<< "$artifact" gh api $url > "$name.zip" unzip -d "$name" "$name.zip" done @@ -41,4 +34,6 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@v1 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"