1- name : " Remind to run update_dependency.sh "
1+ name : Request Lockfile Review
22
33on :
44 pull_request :
55 branches : ["master"]
66 types : [opened, synchronize, reopened]
77
88jobs :
9- review-lockfiles :
9+ # 1. This job runs safely with NO write permissions.
10+ # It is perfectly safe to check out the untrusted fork code here.
11+ scan-lockfiles :
1012 runs-on : ubuntu-latest
11- permissions :
12- pull-requests : write
13- contents : read
14-
13+ outputs :
14+ any_changed : ${{ steps.changed-files.outputs.any_changed }}
15+ pr_number : ${{ github.event.pull_request.number }}
1516 steps :
1617 - name : Checkout repository
1718 uses : actions/checkout@v4
@@ -23,15 +24,46 @@ jobs:
2324 files : |
2425 **/*.lockfile
2526
27+ # Save the results so the privileged job can read them
28+ - name : Save scan results
29+ run : |
30+ mkdir -p ./results
31+ echo "${{ steps.changed-files.outputs.any_changed }}" > ./results/any_changed.txt
32+ echo "${{ github.event.pull_request.number }}" > ./results/pr_number.txt
33+
34+ - name : Upload artifact
35+ uses : actions/upload-artifact@v4
36+ with :
37+ name : lockfile-scan-results
38+ path : ./results/
39+
40+ # 2. This job runs sequentially, but ONLY handles the write operation.
41+ # It never checks out the untrusted PR code, making it completely secure.
42+ comment-lockfiles :
43+ needs : scan-lockfiles
44+ # Only run if the previous scan detected a lockfile change
45+ if : needs.scan-lockfiles.outputs.any_changed == 'true'
46+ runs-on : ubuntu-latest
47+ permissions :
48+ pull-requests : write
49+ steps :
50+ - name : Download artifact
51+ uses : actions/download-artifact@v4
52+ with :
53+ name : lockfile-scan-results
54+ path : ./results
55+
2656 - name : Post unresolved review comment
27- if : steps.changed-files.outputs.any_changed == 'true'
2857 uses : actions/github-script@v7
2958 with :
3059 script : |
60+ const fs = require('fs');
61+ const prNumber = fs.readFileSync('./results/pr_number.txt', 'utf8').trim();
62+
3163 github.rest.pulls.createReview({
3264 owner: context.repo.owner,
3365 repo: context.repo.repo,
34- pull_number: context.payload.pull_request.number ,
66+ pull_number: parseInt(prNumber, 10) ,
3567 event: 'COMMENT',
3668 body: `### ⚠️ Attention Required: Lockfile Detected\nThis pull request contains modifications to one or more \`*.lockfile\` files. Please confirm that you have run update_dependency.sh to push new dependencies to the private repo.\n\n_The PR author must manually mark this conversation as resolved before merging._`
3769 })
0 commit comments