-
Notifications
You must be signed in to change notification settings - Fork 197
refactor automerge github action to be more efficient #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
refactor automerge github action to be more efficient #346
Conversation
| echo "Checking branch protection rules for ${BASE_BRANCH}..." | ||
| # Make a single API call to get branch protection info | ||
| branch_protection_json=$(gh api repos/${REPO}/branches/${BASE_BRANCH}/protection --silent 2>/dev/null || echo '{}') | ||
| # Check if required_status_checks is present (not null) | ||
| if ! echo "$branch_protection_json" | jq -e '.required_status_checks != null' > /dev/null; then | ||
| echo "::error::Branch protection for ${BASE_BRANCH} does not require status checks. Exiting." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Branch protection with required status checks is properly configured." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure if this would actually run properly with the default workflow secrets.GITHUB_TOKEN permissions.
I'm also not sure if it's actually needed if we leave this action triggering on check_suite completed. Originally I was going to have the action still trigger on pull_request, but only enable automerge if branch protections + require status checks were enabled, as a failsafe to ensure it wasn't merged prematurely if those protections weren't enabled.
If we're sure that they are enabled for the repo, it may also be fine to just remove the check from this action entirely; in which case it would probably be equally correct to have it trigger on pull_request, or check_suite completed; as the branch protections would be sufficient to ensure it only merges when the checks complete successfully:
|
A PR was automerged recently, despite there being failing tests (#382 (comment)); which I think is a bug/limitation in the current automerge, that would likely be resolved by this PR:
Edit: See the following issue: |
The previous automerge action runs on
pull_request, and polls/sleeps until checks have been completed.This refactored version instead runs on
check_suitecompleted.Note: I haven't fully tested this, so I'm not 100% sure if it will work as is, but wanted to raise it for a discussion point.
See Also