Comment CI test results on PR #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment CI test results on PR | |
on: | |
workflow_run: | |
workflows: ["CI"] | |
types: | |
- completed | |
jobs: | |
comment: | |
strategy: | |
matrix: | |
# Sync with matrix in ci.yml | |
runs-on: [ubuntu-latest] | |
runs-on: ${{ matrix.runs-on }} | |
permissions: | |
# list and download | |
actions: read | |
# post results as comment | |
pull-requests: write | |
# publish creates a check run | |
checks: write | |
steps: | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "test-results-${{ matrix.runs-on }}" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/test-results.zip', Buffer.from(download.data)); | |
- id: unpack | |
run: | | |
mkdir -p test-results | |
unzip -d test-results test-results.zip | |
echo "sha=$(cat test-results/sha-number)" >> $GITHUB_OUTPUT | |
- uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
commit: ${{ steps.unpack.outputs.sha }} | |
check_name: Unit Test Results | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
files: "**/test-results/**/*.xml" |