@@ -3,13 +3,17 @@ name: PythonBot - Check Merge Conflicts
33on :
44 pull_request_target :
55 types : [opened, synchronize, reopened]
6+ push :
7+ branches :
8+ - main
69
710permissions :
811 contents : read
912 pull-requests : write
1013
1114concurrency :
12- group : " check-conflicts-${{ github.event.pull_request.number }}"
15+ # Use PR number if available, otherwise use the Commit SHA
16+ group : " check-conflicts-${{ github.event.pull_request.number || github.sha }}"
1317 cancel-in-progress : true
1418
1519jobs :
@@ -26,10 +30,21 @@ jobs:
2630 env :
2731 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2832 run : |
29- PR_NUMBER=${{ github.event.pull_request.number }}
3033 REPO="${{ github.repository }}"
34+ # 1. Determine which PRs to check
35+ if [ "${{ github.event_name }}" == "push" ]; then
36+ echo "Triggered by push to main. Fetching all open PRs..."
37+ PR_NUMBERS=$(gh pr list --repo $REPO --state open --json number --jq '.[].number')
38+ else
39+ echo "Triggered by PR update."
40+ PR_NUMBERS="${{ github.event.pull_request.number }}"
41+ fi
3142
32- echo "Checking merge status for PR #$PR_NUMBER in repository $REPO..."
43+ # 2. Loop through the list (works for 1 PR or 100 PRs)
44+ for PR_NUMBER in $PR_NUMBERS; do
45+ echo "---------------------------------------------------"
46+ echo "Checking merge status for PR #$PR_NUMBER in repository $REPO..."
47+
3348
3449 for i in {1..10}; do
3550 PR_JSON=$(gh api repos/$REPO/pulls/$PR_NUMBER)
6378 )
6479
6580 gh pr view $PR_NUMBER --repo $REPO --json comments --jq '.comments[].body' | grep -F "MergeConflictBot" >/dev/null || \
66- (gh pr comment $PR_NUMBER --repo $REPO --body "$COMMENT" && echo "Comment added to PR #$PR_NUMBER")
67-
68- exit 1
69- else
70- echo "No merge conflicts detected (State: $MERGEABLE_STATE)."
71- fi
81+ (gh pr comment $PR_NUMBER --repo $REPO --body "$COMMENT" && echo "Comment added to PR #$PR_NUMBER")
82+
83+ # REMOVED 'exit 1' here so the loop continues!
84+ else
85+ echo "No merge conflicts detected for PR #$PR_NUMBER (State: $MERGEABLE_STATE)."
86+ fi
87+ done
0 commit comments