feat: track post-merge CI/CD runs in ci-watcher#20
Conversation
- Add `gh pr merge` as trigger alongside push/pr create - Resolve merge commit SHA from PR metadata for accurate run tracking - Retry SHA resolution if merge isn't complete yet Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a781f2f384
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [ -z "$REPO" ]; then exit 0; fi | ||
| if [ "$TRIGGER" = "merge" ]; then | ||
| # Extract PR number from command (gh pr merge 123 or gh pr merge URL) | ||
| PR_NUM=$(echo "$CMD" | grep -oE 'gh pr merge [^ ]+' | awk '{print $NF}' | grep -oE '[0-9]+' | head -1) |
There was a problem hiding this comment.
Parse
gh pr merge target without assuming numeric arg
The new merge path only derives PR_NUM by extracting digits from the first token after gh pr merge, so it exits for valid invocations like gh pr merge (no argument), branch-name arguments, or flag-first forms. The GitHub CLI synopsis allows [<number> | <url> | <branch>] and also supports no argument (current branch PR), so this parser causes the watcher to silently skip post-merge CI tracking for common merge flows.
Useful? React with 👍 / 👎.
| if [ -z "$SHA" ]; then | ||
| # Merge might not be complete yet, wait and retry | ||
| sleep 5 | ||
| PR_JSON=$(gh pr view "$PR_NUM" --repo "$REPO" --json mergeCommit,baseRefName 2>/dev/null || echo "{}") | ||
| SHA=$(echo "$PR_JSON" | jq -r '.mergeCommit.oid // empty' 2>/dev/null) |
There was a problem hiding this comment.
Wait for delayed merge completion before bailing out
This logic retries mergeCommit only once after 5 seconds, then aborts tracking when it is still empty. gh pr merge --auto and merge-queue paths can intentionally delay the actual merge until checks pass, so in those cases this script exits before the merge commit exists and never watches the CI/CD runs it was added to track.
Useful? React with 👍 / 👎.
- Problem-first framing: CI polling, manual log pasting, deploy checking - Add build error auto-report example (both EN/KO) - Reposition event abstraction layer explanation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
gh pr merge후 base 브랜치에서 돌아가는 CI/CD run도 추적Test plan
gh pr merge후 CI/CD 알림 수신 확인🤖 Generated with Claude Code