Skip to content

Conversation

@0xdevalias
Copy link
Contributor

@0xdevalias 0xdevalias commented Feb 25, 2025

Comment on lines +26 to +37
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."
Copy link
Contributor Author

@0xdevalias 0xdevalias Feb 25, 2025

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:

@0xdevalias
Copy link
Contributor Author

0xdevalias commented Mar 28, 2025

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:

So this seems like it never should have passed and been able to be merged.. probably a race condition/similar bug in the automerge GitHub action that likely would be resolved by the improvements raised in:

Originally posted by @0xdevalias in #382 (comment)

Edit: See the following issue:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant