Skip to content

feat: track post-merge CI/CD runs in ci-watcher#20

Merged
chsm04 merged 2 commits intomainfrom
feat/ci-watcher-merge-tracking
Mar 25, 2026
Merged

feat: track post-merge CI/CD runs in ci-watcher#20
chsm04 merged 2 commits intomainfrom
feat/ci-watcher-merge-tracking

Conversation

@chsm04
Copy link
Copy Markdown
Owner

@chsm04 chsm04 commented Mar 25, 2026

Summary

  • gh pr merge 후 base 브랜치에서 돌아가는 CI/CD run도 추적
  • 머지 커밋 SHA를 PR 메타데이터에서 가져와서 정확한 run 추적
  • push/pr create/merge 세 가지 트리거 지원

Test plan

  • gh pr merge 후 CI/CD 알림 수신 확인
  • 기존 push/pr create 트리거 정상 동작 확인

🤖 Generated with Claude Code

- 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>
Copy link
Copy Markdown

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

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: 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".

Comment thread examples/ci-watcher.sh
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)
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 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 👍 / 👎.

Comment thread examples/ci-watcher.sh
Comment on lines +118 to +122
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)
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 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>
@chsm04 chsm04 merged commit 21498f4 into main Mar 25, 2026
1 check 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.

1 participant