@@ -285,12 +285,22 @@ wp @staging cache flush
285285# 9. Mark PR as ready for review
286286gh pr ready
287287
288- # 10. Wait for both CI and Copilot review to complete
289- # Check status (don't merge until both are done):
290- gh pr view < pr-number> --json reviews,reviewRequests
291-
292- # 11. After all reviews complete, merge
293- gh pr checks < pr-number> --watch && gh pr merge < pr-number> -m -d --admin
288+ # 10. Wait for CI to pass
289+ gh pr checks < pr-number> --watch
290+
291+ # 11. Wait for Copilot review workflow to complete (DON'T SKIP THIS)
292+ while true ; do
293+ REVIEW=$( gh pr view < pr-number> --json reviews -q ' .reviews[] | select(.author.login == "copilot-pull-request-reviewer") | .submittedAt' )
294+ if [ -n " $REVIEW " ]; then
295+ echo " ✓ Copilot review complete"
296+ break
297+ fi
298+ echo " ⏳ Waiting for Copilot review workflow... (30s)"
299+ sleep 30
300+ done
301+
302+ # 12. After BOTH CI and Copilot workflow complete, merge
303+ gh pr merge < pr-number> -m -d --admin
294304```
295305
296306### Pattern 2: Address PR Code Review Comments
@@ -328,11 +338,22 @@ gh pr edit <pr-number> --add-reviewer @copilot
328338# 9. Deploy to staging to verify all fixes
329339git push origin HEAD:staging --force
330340
331- # 10. Wait for new Copilot review to complete, then merge
332- # Check review status first
333- gh pr view < pr-number> --json reviews,reviewRequests
334- # After Copilot review is complete (not just CI):
335- gh pr checks < pr-number> --watch && gh pr merge < pr-number> -m -d --admin
341+ # 10. Wait for CI checks to pass
342+ gh pr checks < pr-number> --watch
343+
344+ # 11. Wait for Copilot review workflow to complete
345+ while true ; do
346+ REVIEW=$( gh pr view < pr-number> --json reviews -q ' .reviews[] | select(.author.login == "copilot-pull-request-reviewer") | .submittedAt' )
347+ if [ -n " $REVIEW " ]; then
348+ echo " ✓ Copilot review complete"
349+ break
350+ fi
351+ echo " ⏳ Waiting for Copilot review workflow... (30s)"
352+ sleep 30
353+ done
354+
355+ # 12. After both CI and Copilot workflow complete, merge
356+ gh pr merge < pr-number> -m -d --admin
336357```
337358
338359### Pattern 3: Implement New Feature from ClickUp
@@ -385,11 +406,22 @@ git push origin HEAD:staging --force
385406# 7. Mark ready and get review
386407gh pr ready
387408
388- # 10. Wait for CI checks AND Copilot review, then merge
389- # IMPORTANT: Check that @copilot review is complete (not just CI)
390- gh pr view < pr-number> --json reviewRequests,reviews
391- # If no pending review requests and Copilot has reviewed, proceed:
392- gh pr checks < pr-number> --watch && gh pr merge < pr-number> -m -d --admin
409+ # 8. Wait for CI to pass
410+ gh pr checks < pr-number> --watch
411+
412+ # 9. Wait for Copilot review workflow to complete (REQUIRED)
413+ while true ; do
414+ REVIEW=$( gh pr view < pr-number> --json reviews -q ' .reviews[] | select(.author.login == "copilot-pull-request-reviewer") | .submittedAt' )
415+ if [ -n " $REVIEW " ]; then
416+ echo " ✓ Copilot review complete"
417+ break
418+ fi
419+ echo " ⏳ Waiting for Copilot review workflow... (30s)"
420+ sleep 30
421+ done
422+
423+ # 10. After both CI and Copilot workflow complete, merge
424+ gh pr merge < pr-number> -m -d --admin
393425
394426# 9. Verify production deployment
395427# (happens automatically when default branch is pushed)
@@ -587,9 +619,10 @@ When implementing a feature or fix:
5876197 . ** Address code review feedback** - Validate accuracy, reply in threads, resolve when fixed
5886208 . ** Deploy to staging for testing** - ` git push origin <branch>:staging --force `
5896219 . ** Verify changes on staging** - Test that the fix/feature works correctly
590- 10 . ** Wait for reviews to complete** - Check both CI and Copilot review status with ` gh pr view <pr> --json reviews,reviewRequests `
591- 11 . ** Merge to default branch** - After all reviews complete: ` gh pr checks <pr> --watch && gh pr merge <pr> -m -d --admin `
592- 12 . ** Production deployment** - Happens automatically when default branch is pushed
622+ 10 . ** Wait for CI checks to pass** - ` gh pr checks <pr> --watch `
623+ 11 . ** Wait for Copilot review workflow to complete** - Use loop to check for review from copilot-pull-request-reviewer
624+ 12 . ** Merge to default branch** - ` gh pr merge <pr> -m -d --admin ` (only after both CI and Copilot review complete)
625+ 13 . ** Production deployment** - Happens automatically when default branch is pushed
593626
594627** Key points:**
595628- Always verify on staging BEFORE merging to default branch
@@ -707,32 +740,105 @@ Use `gh-pr-get-comments` script to retrieve all comments on a PR:
707740
708741### Merging to Default Branch
709742
710- ** IMPORTANT: Wait for ALL reviews (not just CI) before merging:**
743+ ** 🚨 CRITICAL: NEVER merge until BOTH CI passes AND Copilot review workflow completes**
744+
745+ ** The Problem:** Copilot review runs as a GitHub Actions workflow that takes 1-3 minutes. If you merge before it completes, you'll miss critical bugs.
746+
747+ ** How Copilot Review Works:**
748+ - Triggered automatically when PR is created/updated
749+ - Runs as "Copilot code review" GitHub Actions workflow
750+ - Takes 1-3 minutes to analyze code and post review
751+ - Must wait for workflow to complete, not just CI checks
752+
753+ ** Required Workflow:**
711754
712755``` bash
713- # 1. Check review status (do this BEFORE merging)
714- gh pr view < pr-number> --json reviews,reviewRequests
756+ # 1. Wait for CI checks (Lint, etc.)
757+ gh pr checks < pr-number> --watch
758+
759+ # 2. Wait for Copilot review workflow to complete (REQUIRED - don't skip!)
760+ while true ; do
761+ # Check if Copilot review workflow is complete
762+ REVIEW=$( gh pr view < pr-number> --json reviews -q ' .reviews[] | select(.author.login == "copilot-pull-request-reviewer") | .submittedAt' )
763+ if [ -n " $REVIEW " ]; then
764+ echo " ✓ Copilot review complete at $REVIEW "
765+ break
766+ fi
767+ echo " ⏳ Waiting for Copilot review workflow... (checking again in 30s)"
768+ sleep 30
769+ done
770+
771+ # 3. Now safe to merge
772+ gh pr merge < pr-number> -m -d --admin
773+ ```
715774
716- # Look for:
717- # - "reviewRequests": [] (empty means no pending review requests)
718- # - "reviews": [...] (should include copilot-pull-request-reviewer)
775+ ** Alternative - Check workflow runs directly:**
776+ ``` bash
777+ # Wait for CI
778+ gh pr checks < pr-number> --watch
779+
780+ # Get PR number from branch
781+ PR_NUM=$( gh pr view --json number -q .number)
782+
783+ # Wait for Copilot review workflow to complete
784+ while true ; do
785+ STATUS=$( gh run list --repo $( gh repo view --json nameWithOwner -q .nameWithOwner) \
786+ --workflow=" Copilot code review" --json headBranch,status,conclusion \
787+ --jq " .[] | select(.headBranch == \" refs/pull/${PR_NUM} /head\" ) | .status" )
788+
789+ if [ " $STATUS " = " completed" ]; then
790+ echo " ✓ Copilot review workflow complete"
791+ break
792+ fi
793+ echo " ⏳ Copilot review workflow status: $STATUS (checking again in 30s)"
794+ sleep 30
795+ done
796+
797+ # Now safe to merge
798+ gh pr merge < pr-number> -m -d --admin
799+ ```
800+
801+ ** How to check manually:**
802+ ``` bash
803+ # Check if Copilot review exists (posted by workflow)
804+ gh pr view < pr-number> --json reviews -q ' .reviews[] | select(.author.login == "copilot-pull-request-reviewer")'
719805
720- # 2. If Copilot review is still pending, WAIT
721- # Copilot reviews can take 1-3 minutes after CI passes
806+ # If empty: workflow hasn't completed yet - WAIT
807+ # If shows data: workflow complete - OK TO MERGE
722808
723- # 3. Only merge after BOTH CI checks pass AND reviews complete
724- gh pr checks < pr-number> --watch --interval 2 && gh pr merge < pr-number> -m -d --admin
809+ # Or check workflow run status
810+ gh run list --workflow=" Copilot code review" --limit 5
811+ ```
812+
813+ ** WRONG (what causes the problem):**
814+ ``` bash
815+ # ❌ BAD: Merges after CI only, doesn't wait for Copilot review workflow
816+ gh pr checks < pr-number> --watch && gh pr merge < pr-number> -m -d --admin
725817```
726818
727- - Before merging, ensure:
728- 1 . Most recent commit was deployed to staging and verified
729- 2 . CI checks have passed
730- 3 . Copilot review has completed (not just requested)
731- 4 . Any review comments have been addressed
732- - Or use the alias: ` gh_check_merge <pr-number> --admin ` (but check reviews first manually)
733- - The ` --admin ` flag bypasses branch protection rules
734- - The ` -m -d ` flags merge and delete the branch after merging
735- - ** Note** : This is only for merging to the default branch, NOT for deploying to staging
819+ ** Before merging, verify ALL of these:**
820+ 1 . ✅ Most recent commit was deployed to staging and verified
821+ 2 . ✅ CI checks (Lint, etc.) have passed
822+ 3 . ✅ Copilot review workflow has completed (review posted by copilot-pull-request-reviewer)
823+ 4 . ✅ Any review comments have been addressed
824+
825+ ** Real examples of the problem:**
826+ - PR #147 : Merged 43s after creation, review workflow completed at 2m24s
827+ - PR #149 : Merged at 00:01:51, review workflow completed at 00:03:02 (1m11s after merge)
828+ - PR #150 : Merged at 00:06:56, review workflow completed at 00:07:05 (9s after merge - close!)
829+
830+ ** Timing data:**
831+ - Copilot review workflow starts ~ 5 seconds after PR created
832+ - Workflow takes 1-3 minutes to complete
833+ - CI checks usually complete in <1 minute
834+ - ** Problem:** CI finishes before review workflow
835+
836+ ** ⚠️ Do NOT use:**
837+ - ` gh_check_merge ` alias (only waits for CI, not Copilot workflow)
838+ - ` gh pr checks --watch && gh pr merge ` (skips Copilot workflow check)
839+ - Any command that merges immediately after CI passes
840+
841+ ** This is only for merging to default branch** , NOT for deploying to staging.
736842
737843### After Pushing
738844
@@ -1199,14 +1305,20 @@ git push -u origin HEAD
11991305# Open draft PR
12001306gh pr create --draft --fill
12011307
1202- # Check review status (before merging)
1203- gh pr view < pr-number> --json reviews,reviewRequests
1308+ # Wait for CI and Copilot review workflow, then merge
1309+ gh pr checks < pr-number> --watch
12041310
1205- # Check CI status and merge (only after reviews complete)
1206- gh pr checks < pr-number> --watch && gh pr merge < pr-number> -m -d --admin
1311+ # Wait for Copilot review workflow to complete
1312+ while true ; do
1313+ REVIEW=$( gh pr view < pr-number> --json reviews -q ' .reviews[] | select(.author.login == "copilot-pull-request-reviewer") | .submittedAt' )
1314+ if [ -n " $REVIEW " ]; then
1315+ break
1316+ fi
1317+ sleep 30
1318+ done
12071319
1208- # Or use alias
1209- gh_check_merge < pr-number> --admin
1320+ # After BOTH complete, merge
1321+ gh pr merge < pr-number> -m -d --admin
12101322
12111323# Deploy any branch to staging
12121324git push origin < branch-name> :staging --force
0 commit comments