|
10 | 10 | workflow_run: |
11 | 11 | workflows: |
12 | 12 | - CI |
| 13 | + - Publish |
| 14 | + - Release |
13 | 15 | types: |
14 | 16 | - completed |
| 17 | +permissions: {} |
15 | 18 |
|
16 | 19 | jobs: |
17 | | - # Job based on https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ |
| 20 | + # Job based on |
| 21 | + # - https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ |
| 22 | + # - https://github.com/marketplace/actions/publish-test-results#support-fork-repositories-and-dependabot-branches |
18 | 23 | publish-test-results: |
19 | 24 | runs-on: ubuntu-latest |
20 | | - if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 25 | + if: github.event.workflow_run.conclusion != 'skipped' |
| 26 | + |
| 27 | + permissions: |
| 28 | + checks: write |
| 29 | + # needed unless run with comment_mode: off |
| 30 | + pull-requests: write |
| 31 | + # only needed for private repository |
| 32 | + #contents: read |
| 33 | + # only needed for private repository |
| 34 | + #issues: read |
| 35 | + # required by download step to access artifacts API |
| 36 | + actions: read |
| 37 | + |
21 | 38 | steps: |
22 | | - # Unfortunately, the official actions/download-artifact action is very limited in scope. |
23 | | - # Can't use it yet in this context, https://github.com/actions/download-artifact/issues/60 |
24 | | - - name: Download artifact |
25 | | - uses: actions/github-script@v6 |
| 39 | + - name: Download and Extract Artifacts |
| 40 | + uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 |
26 | 41 | with: |
27 | | - script: | |
28 | | - var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
29 | | - owner: context.repo.owner, |
30 | | - repo: context.repo.repo, |
31 | | - run_id: ${{ github.event.workflow_run.id }}, |
32 | | - }); |
33 | | - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
34 | | - return artifact.name == "test-results" |
35 | | - })[0]; |
36 | | - var download = await github.rest.actions.downloadArtifact({ |
37 | | - owner: context.repo.owner, |
38 | | - repo: context.repo.repo, |
39 | | - artifact_id: matchArtifact.id, |
40 | | - archive_format: 'zip', |
41 | | - }); |
42 | | - var fs = require('fs'); |
43 | | - fs.writeFileSync('${{github.workspace}}/test-results.zip', Buffer.from(download.data)); |
44 | | - - run: unzip test-results.zip |
| 42 | + run_id: ${{ github.event.workflow_run.id }} |
| 43 | + path: artifacts |
45 | 44 | - name: Publish Test Results |
46 | | - uses: scacap/action-surefire-report@v1 |
| 45 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
47 | 46 | with: |
48 | | - commit: ${{ github.event.workflow_run.head_commit.id }} |
49 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
50 | | - report_paths: '**/build/test-results/test/TEST-*.xml' |
| 47 | + commit: ${{ github.event.workflow_run.head_sha }} |
| 48 | + event_file: artifacts/event-file/event.json |
| 49 | + event_name: ${{ github.event.workflow_run.event }} |
| 50 | + files: "artifacts/**/build/test-results/test/TEST-*.xml" |
| 51 | +... |
0 commit comments