Skip to content

Commit 7e6602d

Browse files
committed
Add CommentPR.yml to prepare for breakage change
1 parent 4bf23c1 commit 7e6602d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/CommentPR.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Ref: https://securitylab.github.com/research/github-actions-preventing-pwn-requests
2+
name: Comment on the pull request
3+
4+
# read-write repo token
5+
# access to secrets
6+
on:
7+
workflow_run:
8+
workflows: ["Breakage"]
9+
types:
10+
- completed
11+
12+
jobs:
13+
upload:
14+
runs-on: ubuntu-latest
15+
if: >
16+
${{ github.event.workflow_run.event == 'pull_request' &&
17+
github.event.workflow_run.conclusion == 'success' }}
18+
steps:
19+
- name: 'Download artifact'
20+
uses: actions/github-script@v3.1.0
21+
with:
22+
script: |
23+
var artifacts = await github.actions.listWorkflowRunArtifacts({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
run_id: ${{github.event.workflow_run.id }},
27+
});
28+
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
29+
return artifact.name == "pr"
30+
})[0];
31+
var download = await github.actions.downloadArtifact({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
artifact_id: matchArtifact.id,
35+
archive_format: 'zip',
36+
});
37+
var fs = require('fs');
38+
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
39+
- run: unzip pr.zip
40+
41+
- name: 'Comment on PR'
42+
uses: actions/github-script@v3
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
var fs = require('fs');
47+
var issue_number = Number(fs.readFileSync('./NR'));
48+
var msg = fs.readFileSync('./MSG', 'utf8');
49+
await github.issues.createComment({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
issue_number: issue_number,
53+
body: msg
54+
});

0 commit comments

Comments
 (0)