@@ -11,6 +11,38 @@ permissions:
1111 actions : read
1212
1313jobs :
14+ check-file-changes :
15+ if : github.event.review.state == 'approved'
16+ runs-on : ubuntu-latest
17+ env :
18+ PR_NUMBER : ${{ github.event.pull_request.number }}
19+ SOURCE_REPO : ${{ github.repository }}
20+ outputs :
21+ should_sync : ${{ steps.filter.outputs.should_sync }}
22+ steps :
23+ - name : Check Changed File Paths
24+ id : filter
25+ env :
26+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
27+ run : |
28+ EXCLUDED_PATHS=(
29+ ".github/workflows/"
30+ )
31+
32+ CHANGED_FILES=$(gh pr view $PR_NUMBER --json files --repo $SOURCE_REPO --jq '[.files[].path]')
33+
34+ EXCLUDE_FILTER=$(printf '"%s",' "${EXCLUDED_PATHS[@]}")
35+ EXCLUDE_FILTER="[${EXCLUDE_FILTER%,}]"
36+
37+ NON_WORKFLOW_CHANGES=$(echo "$CHANGED_FILES" | jq --argjson exclude "$EXCLUDE_FILTER" '[.[] | select(. as $f | $exclude | any(. as $p | $f | startswith($p)) | not)] | length')
38+ if [ "$NON_WORKFLOW_CHANGES" -gt 0 ]; then
39+ echo "PR contains changes outside filtered paths — proceeding."
40+ echo "should_sync=true" >> $GITHUB_OUTPUT
41+ else
42+ echo "All changes are under filtered paths — skipping workflow."
43+ echo "should_sync=false" >> $GITHUB_OUTPUT
44+ fi
45+
1446 check-merge-state :
1547 if : github.event.review.state == 'approved'
1648 runs-on : ubuntu-latest
95127 echo "Auto-merge enabled successfully!"
96128
97129 dispatch-to-internal :
98- needs : check-merge-state
99- if : needs.check-merge-state.outputs.checks_passed == 'true' && github.event.review.state == 'approved'
130+ needs : [ check-file-changes, check- merge-state]
131+ if : needs.check-merge-state.outputs.checks_passed == 'true' && needs.check-file-changes.outputs.should_sync == 'true' && github.event.review.state == 'approved'
100132 runs-on : ubuntu-latest
101133 env :
102134 SOURCE_REPO : github/github-well-architected
0 commit comments