Skip to content

fix: use --auto flag for merging PRs with branch protection#31

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/auto-merge-with-branch-protection
Mar 22, 2026
Merged

fix: use --auto flag for merging PRs with branch protection#31
github-actions[bot] merged 1 commit into
mainfrom
fix/auto-merge-with-branch-protection

Conversation

@vinitu

@vinitu vinitu commented Mar 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add --auto flag to gh pr merge in the reusable merge workflow
  • Without it, repos with branch protection (required status checks) block the merge immediately
  • With --auto, GitHub queues the PR and merges it once all checks pass

Test plan

🤖 Generated with Claude Code

When branch protection requires status checks, direct merge is blocked.
The --auto flag queues the PR for merge once all checks pass.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot merged commit f9a6029 into main Mar 22, 2026
3 checks passed
@github-actions github-actions Bot deleted the fix/auto-merge-with-branch-protection branch March 22, 2026 07:55

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 587841ea41

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


echo "Merging PR #$number with method $merge_method..."
gh pr merge "$number" -R "$REPO" "$merge_flag" --delete-branch --body "Merged automatically after successful CI."
gh pr merge "$number" -R "$REPO" "$merge_flag" --auto --delete-branch --body "Merged automatically after successful CI."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Don't mark --auto PRs as merged before the merge happens

The GitHub CLI manual says gh pr merge --auto will merge "only after necessary requirements are met", so this command can succeed before the PR is actually on main. This workflow still sets merged_any=true immediately afterward, and .github/workflows/ci-pr.yml:74-114 uses that output to trigger workflow-compute-next-tag.yml and workflow-create-tag.yml, which check out main and tag its current HEAD. On protected branches where a required review/check is still pending, this will publish a tag/release from the pre-merge commit and report the PR as merged even if auto-merge never completes.

Useful? React with 👍 / 👎.


echo "Merging PR #$number with method $merge_method..."
gh pr merge "$number" -R "$REPO" "$merge_flag" --delete-branch --body "Merged automatically after successful CI."
gh pr merge "$number" -R "$REPO" "$merge_flag" --auto --delete-branch --body "Merged automatically after successful CI."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid requiring repository auto-merge for every reusable caller

GitHub's auto-merge docs require auto-merge to be enabled at the repository level before a PR can use --auto. Because this reusable workflow now passes --auto unconditionally, any consumer repo that has not turned on the separate "Allow auto-merge" setting will fail here even when the PR is otherwise ready to merge. Since README.md:50-73 advertises this workflow for general reuse, this change is a breaking regression for callers that previously worked with the plain gh pr merge path.

Useful? React with 👍 / 👎.

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