Comment on the pull request #100
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 the pull request | |
on: | |
workflow_run: | |
workflows: ["Continuous Integration"] | |
types: | |
- completed | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: 'Download artifact' | |
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 == "coverage" | |
})[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}}/coverage.zip', Buffer.from(download.data)); | |
- name: Unzip coverage artifact | |
run: unzip coverage.zip | |
- id: pull-request | |
run: | | |
echo "::set-output name=number::$(cat pull-request-number)" | |
- name: Add coverage PR comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
number: ${{ steps.pull-request.outputs.number }} | |
hide_and_recreate: true | |
hide_classify: "OUTDATED" | |
path: coverage.txt | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |