Label validated Pull Request #44
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
--- | |
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | |
name: Label validated Pull Request | |
on: | |
workflow_run: | |
workflows: ["Validate Pull Request"] | |
types: | |
- completed | |
jobs: | |
label: | |
permissions: | |
contents: read | |
pull-requests: write | |
runs-on: ubuntu-latest | |
if: > | |
github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' | |
steps: | |
- name: Download the PR number artifact | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "pr_number" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); | |
- name: 'Unzip artifact' | |
run: unzip pr_number.zip | |
- name: Read the PR number | |
id: read | |
run: echo "pr_number=$(cat pr_number)" >> $GITHUB_OUTPUT | |
- name: Label the PR | |
uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
labels: validated | |
number: ${{ steps.read.outputs.pr_number }} |