Skip to content

feat(pr): add --auto-merge flag to merge PR when CI passes#501

Merged
ricky-undeadcoders merged 1 commit intografana:mainfrom
julienduchesne:julienduchesne/auto-merge-pr
Apr 8, 2026
Merged

feat(pr): add --auto-merge flag to merge PR when CI passes#501
ricky-undeadcoders merged 1 commit intografana:mainfrom
julienduchesne:julienduchesne/auto-merge-pr

Conversation

@julienduchesne
Copy link
Copy Markdown
Contributor

Summary

  • Adds a --auto-merge flag (also $GITHUB_AUTO_MERGE env var) to wait-for-github pr
  • When enabled, once all CI checks pass the PR is automatically merged via the GitHub API
  • The head SHA at the time of the CI check is forwarded to the merge API to prevent a TOCTOU race (new push arriving between CI passing and merge)
  • Merge failures (conflicts, branch protection) are logged as warnings and retried on each poll; the global --timeout bounds the total wait
  • After a successful merge call, the tool continues polling until GitHub confirms the PR as merged, then exits 0

When --auto-merge is enabled, the PR is automatically merged once all CI
checks pass. The head SHA is forwarded to the merge API to prevent a TOCTOU
race where a new push arrives between the CI check and the merge. Merge
failures are retried on each poll interval; the global timeout bounds
the wait.
@julienduchesne julienduchesne requested a review from a team as a code owner March 31, 2026 16:14
@ricky-undeadcoders ricky-undeadcoders added this pull request to the merge queue Apr 8, 2026
Merged via the queue into grafana:main with commit aeca03c Apr 8, 2026
16 checks passed
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.

2 participants