File tree Expand file tree Collapse file tree 1 file changed +7
-31
lines changed Expand file tree Collapse file tree 1 file changed +7
-31
lines changed Original file line number Diff line number Diff line change 11name : PR Workflow Check
22
33on :
4- pull_request_target : ~
4+ pull_request_target :
5+ paths :
6+ - " .github/**"
57
68jobs :
79 check :
10+ if : ${{ github.event.pull_request.head.repo.fork }}
811 runs-on : ubuntu-latest
912 steps :
10- - name : Checkout merge commit
11- uses : actions/checkout@v4
12- with :
13- ref : " refs/pull/${{ github.event.number }}/merge"
14- fetch-depth : 2
15-
16- - name : Check changes to .github
17- if : ${{ github.event.pull_request.head.repo.fork }}
18- id : check
19- run : |
20- echo "==> Changed files:"
21- git diff --name-only HEAD^1 HEAD
22- count=$(git diff --name-only HEAD^1 HEAD | grep -c '^\.github/') || count=0
23-
24- if [[ $count -gt 0 ]]; then
25- echo "==> Found $count violations!"
26- echo "==> Violating files"
27- git diff --name-only HEAD^1 HEAD | grep '^\.github/' || echo "--None--"
28- echo "::error::PR is trying to change a workflow!"
29- echo "bad=true" >> "$GITHUB_OUTPUT"
30- exit 1
31- else
32- echo "All OK"
33- echo "bad=false" >> "$GITHUB_OUTPUT"
34- fi
35-
3613 - name : Comment PR
37- if : ${{ always() && github.event.pull_request.head.repo.fork && steps.check.outputs.bad == 'true' }}
3814 uses : actions/github-script@v7
3915 with :
4016 script : |
4723 > Proceed with caution and if not sure, contact your GitHub admin.`
4824 })
4925
50- - if : ${{ !github.event.pull_request.head.repo.fork }}
51- run : |
52- echo "Not a PR from fork."
26+ - run : |
27+ ::error::PR originating from a fork changes a Github workflow!
28+ exit 1
You can’t perform that action at this time.
0 commit comments