Comment #56
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 | |
on: | |
workflow_run: | |
workflows: | |
- Check | |
types: | |
- completed | |
jobs: | |
comment: | |
name: Comment on PR | |
runs-on: ubuntu-latest | |
if: > | |
github.event.workflow_run.event == 'pull_request' | |
steps: | |
- name: Download tapview results | |
uses: actions/[email protected] | |
with: | |
script: | | |
var artifacts = await github.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" | |
})[0]; | |
var download = await github.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)); | |
- name: Unzip results | |
run: unzip test-results.zip | |
- run: ls -lR | |
- name: Post comment to PR | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
var fs = require('fs'); | |
var issue_number = Number(fs.readFileSync('./PR')); | |
var body = String(fs.readFileSync('test-results.txt')); | |
await github.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
body: body | |
}); |