ci: request a Copilot review once CI first passes on a PR to main - #1016
Open
alongd wants to merge 1 commit into
Open
ci: request a Copilot review once CI first passes on a PR to main#1016alongd wants to merge 1 commit into
alongd wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1016 +/- ##
==========================================
- Coverage 64.56% 64.52% -0.05%
==========================================
Files 119 119
Lines 39706 39706
Branches 10289 10289
==========================================
- Hits 25638 25619 -19
- Misses 11085 11102 +17
- Partials 2983 2985 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds .github/workflows/copilot-review.yml. It listens on workflow_run for the "CI" workflow completing successfully and, for a PR targeting main, requests a Copilot code review exactly once — the first time CI is green. A dedup check (skip if Copilot is already a requested reviewer or has already reviewed) keeps it to a single pass rather than re-firing on every subsequent green push. Chosen over a copilot_code_review branch ruleset, which can only fire on PR open or on every push and cannot gate on CI passing — so it would review red branches and burn Copilot's premium-request quota on them.
alongd
force-pushed
the
copilot-review-on-green
branch
from
August 23, 2026 05:17
85a0c5d to
7b20a03
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions workflow that waits for the repository’s existing CI workflow to complete successfully on a PR targeting main, then requests a Copilot code review exactly once per PR via a dedup check.
Changes:
- Introduces a
workflow_runlistener gated onconclusion == successandevent == pull_request. - Resolves the PR from the workflow_run payload (with a fork fallback) and requests
copilot-pull-request-reviewer[bot]. - Avoids repeat requests by skipping if Copilot is already requested or has already reviewed.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+37
to
+40
| if [ -z "$pr" ]; then | ||
| pr=$(gh pr list --repo "$REPO" --state open --search "$HEAD_SHA" \ | ||
| --json number,baseRefName --jq '.[] | select(.baseRefName=="main") | .number' | head -1) | ||
| fi |
Comment on lines
+63
to
+66
| # The reviewer login the request API expects (distinct from the review author's slug). | ||
| gh api --method POST "repos/$REPO/pulls/$pr/requested_reviewers" \ | ||
| -f 'reviewers[]=copilot-pull-request-reviewer[bot]' | ||
| echo "Requested Copilot review on #$pr." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
.github/workflows/copilot-review.yml: the first time a PR tomainpasses CI, it requests a Copilot code review — once.How
Listens on
workflow_runfor the CI workflow completing withconclusion == successon apull_request, resolves the PR (event payload for same-repo PRs; head-SHA lookup for forks), and addscopilot-pull-request-reviewer[bot]as a reviewer. A dedup check (skip if Copilot is already requested or has already reviewed) keeps it to one pass per PR — it does not re-fire on later green pushes.Why gated on green, not a ruleset
A
copilot_code_reviewbranch ruleset can only fire on PR open or on every push — it cannot wait for CI. Gating on green keeps Copilot off red branches and off the quota until the branch actually builds, and holds it to a single review.Notes
ci.ymlor any source/test.main; it takes effect on the next PR.permissions: pull-requests: write,contents: read.