Skip to content

Label validated Pull Request #44

Label validated Pull Request

Label validated Pull Request #44

Workflow file for this run

---
# 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 }}