[Backport 2.x] Always run check workflow events on all occasions #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |