Skip to content

Commit 18a9487

Browse files
Add check workflow events related checks (#1128) (#1129)
Signed-off-by: Peter Zhu <[email protected]> (cherry picked from commit 2365ffd) Co-authored-by: Peter Zhu <[email protected]>
1 parent bd5bf76 commit 18a9487

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check Workflow Events
2+
on:
3+
pull_request:
4+
paths:
5+
- '.github/workflows/**'
6+
7+
jobs:
8+
check-workflow-events:
9+
runs-on: ubuntu-latest
10+
name: Check Workflow Events
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Check Workflow Events
14+
working-directory: .github/workflows
15+
run: |
16+
set +e
17+
EVENT_COUNT=0
18+
for file_found in `ls | grep .ym`; do
19+
yq -r e '.on | keys | .[0]' $file_found | grep -q pull_request_target
20+
EVENT_FOUND=$?
21+
22+
if [ "$EVENT_FOUND" = 0 ] && [ "$file_found" != "backport.yml" ] && [ "$file_found" != "copy-linked-issue-labels.yml" ]; then
23+
EVENT_COUNT=$(( EVENT_COUNT+1 ))
24+
echo "'$file_found' workflow file contains 'pull_request_target' event, please remove!"
25+
fi
26+
done
27+
28+
if [ "$EVENT_COUNT" != 0 ]; then
29+
exit 1
30+
fi

0 commit comments

Comments
 (0)