PR Wait and Merge
- •
Check for existing PR: Run
gh pr view --json url,number,state 2>&1to see if a PR already exists for the current branch. - •
Create PR if needed: If no PR exists, create one:
bashgh pr create --title "PR title" --body "$(cat <<'EOF' ## Summary <description based on commits> 🤖 Generated with [Claude Code](https://claude.com/claude-code) EOF )"
To write the title and body, run
git log --oneline main..HEADto understand what commits are included. - •
Wait for CI checks: Poll the PR check status. Use
--watchto wait for all checks to complete:bashgh pr checks --watch --fail-fast
If
--watchis not available, poll manually withgh pr checksevery 30 seconds until all checks have finished. - •
Evaluate results:
- •If any check failed: Report which checks failed and exit. Do NOT merge.
- •If all checks passed: Proceed to merge.
- •
Merge the PR:
bashgh pr merge --squash --delete-branch
- •
Report the result: Print the PR URL and whether it was merged successfully.