Skip to content

[Backport 2.x] Always run check workflow events on all occasions #10

[Backport 2.x] Always run check workflow events on all occasions

[Backport 2.x] Always run check workflow events on all occasions #10

name: Check Workflow Events
on:
pull_request:
jobs:
check-workflow-events:
runs-on: ubuntu-latest
name: Check Workflow Events
steps:
- uses: actions/checkout@v4
- name: Check Workflow Events
working-directory: .github/workflows
run: |
set +e
EVENT_COUNT=0
for file_found in `ls | grep .ym`; do
yq -r e '.on | keys | .[0]' $file_found | grep -q pull_request_target
EVENT_FOUND=$?
if [ "$EVENT_FOUND" = 0 ] && [ "$file_found" != "backport.yml" ] && [ "$file_found" != "copy-linked-issue-labels.yml" ]; then
EVENT_COUNT=$(( EVENT_COUNT+1 ))
echo "'$file_found' workflow file contains 'pull_request_target' event, please remove!"
fi
done
if [ "$EVENT_COUNT" != 0 ]; then
exit 1
fi