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 1
1
name : PR Workflow Check
2
2
3
3
on :
4
- pull_request_target : ~
4
+ pull_request_target :
5
+ paths :
6
+ - " .github/**"
5
7
6
8
jobs :
7
9
check :
10
+ if : ${{ github.event.pull_request.head.repo.fork }}
8
11
runs-on : ubuntu-latest
9
12
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
-
36
13
- name : Comment PR
37
- if : ${{ always() && github.event.pull_request.head.repo.fork && steps.check.outputs.bad == 'true' }}
38
14
uses : actions/github-script@v7
39
15
with :
40
16
script : |
47
23
> Proceed with caution and if not sure, contact your GitHub admin.`
48
24
})
49
25
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