Comment on the pull request (Credentials Scan) #8549
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 (Credentials Scan) | |
# read-write repo token | |
# access to secrets | |
on: | |
workflow_run: | |
workflows: ["Credentials Scan"] | |
types: | |
- completed | |
jobs: | |
# this action will leave a comment in response to credential scans performed on pull requests | |
on-completed: | |
runs-on: ubuntu-22.04 | |
if: github.event.workflow_run.event == 'pull_request' | |
steps: | |
- uses: actions/checkout@v4 | |
- 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 == "pr" | |
})[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}}/pr.zip', Buffer.from(download.data)); | |
- run: unzip pr.zip | |
- name: Comment on PR | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
commentPR () { | |
gh pr comment $PRNUM -b "${1}" | |
} | |
PRNUM=$(cat ./NR) | |
PRBODY=$(cat ./PRBODY) | |
commentPR "$PRBODY" |