Skip to content

Commit fe1518d

Browse files
committed
fix: add PR review loop, Copilot lifecycle workflow, remove assign-to-agent
- Add Phase 8 (PR Review Monitoring & Remediation) to daily pipeline with Copilot review request, comment triage, fix loop, and merge - Create copilot-pr-lifecycle.md workflow for Copilot draft PR handling - Fix reference file paths in daily-intelligence.md (.claude/skills/ prefix) - Update Phase 9 summary template with review/merge stats - Recompile all workflows (0 errors)
1 parent b9e9467 commit fe1518d

7 files changed

Lines changed: 1035 additions & 150 deletions

File tree

.github/aw/actions-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"version": "v9",
66
"sha": "373c709c69115d41ff229c7e5df9f8788daa9553"
77
},
8-
"github/gh-aw-actions/setup@v0.68.1": {
8+
"github/gh-aw-actions/setup@v0.68.3": {
99
"repo": "github/gh-aw-actions/setup",
10-
"version": "v0.68.1",
11-
"sha": "2fe53acc038ba01c3bbdc767d4b25df31ca5bdfc"
10+
"version": "v0.68.3",
11+
"sha": "ba90f2186d7ad780ec640f364005fa24e797b360"
1212
}
1313
}
1414
}

.github/workflows/copilot-pr-lifecycle.lock.yml

Lines changed: 632 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: "Copilot PR Lifecycle"
3+
description: "Marks Copilot-created draft PRs ready, requests review, and enables auto-merge"
4+
timeout-minutes: 5
5+
6+
on:
7+
pull_request:
8+
types: [opened]
9+
10+
if: github.event.pull_request.draft == true && github.event.pull_request.user.login == 'copilot-swe-agent[bot]'
11+
12+
permissions:
13+
contents: read
14+
pull-requests: read
15+
16+
engine:
17+
id: copilot
18+
model: claude-sonnet
19+
20+
tools:
21+
bash: ["gh:*", "echo"]
22+
23+
post-steps:
24+
- name: Mark PR ready for review
25+
env:
26+
GH_TOKEN: ${{ github.token }}
27+
PR_NUMBER: ${{ github.event.pull_request.number }}
28+
run: |
29+
echo "Copilot PR #$PR_NUMBER detected as draft — marking ready"
30+
gh pr ready "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" || true
31+
- name: Request Copilot review
32+
env:
33+
GH_TOKEN: ${{ github.token }}
34+
PR_NUMBER: ${{ github.event.pull_request.number }}
35+
run: |
36+
gh pr edit "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --add-reviewer "@copilot" 2>/dev/null || echo "Copilot reviewer not available"
37+
- name: Enable auto-merge
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
PR_NUMBER: ${{ github.event.pull_request.number }}
41+
run: |
42+
gh pr merge "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --squash --auto --delete-branch || echo "Auto-merge enabled (will merge when approved)"
43+
---
44+
45+
# Copilot PR Lifecycle Handler
46+
47+
## Context
48+
49+
This workflow fires when GitHub Copilot's coding agent opens a draft pull request. Copilot creates draft PRs when assigned to issues, but has no built-in mechanism to mark them ready for review or enable auto-merge.
50+
51+
## Instructions
52+
53+
This is a lifecycle management workflow. The actual work happens in `post-steps`. Your only job is to confirm the PR exists and report its status:
54+
55+
1. Read the PR number from the environment: the PR number is available as `$__GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__`.
56+
57+
2. Check the PR:
58+
59+
```bash
60+
gh pr view "$__GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER__" --repo "$GITHUB_REPOSITORY" --json number,title,isDraft,headRefName,baseRefName
61+
```
62+
63+
3. Report what you found. No edits, no code changes. The `post-steps` block handles the draft-to-ready transition, review request, and auto-merge enablement.

.github/workflows/daily-intelligence.lock.yml

Lines changed: 109 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/daily-intelligence.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ This workflow runs daily around 07:00 via fuzzy schedule, or on-demand via workf
8383
## Reference Files
8484

8585
The following files contain the skill logic and reference data:
86-
- `skills/aw-daily/SKILL.md` — Full 9-phase pipeline logic
87-
- `skills/aw-daily/references/gap-analysis-targets.md` — Reference file inventory for gap analysis
88-
- `skills/aw-daily/references/tracked-repos.md` — GitHub repos to query for activity
89-
- `skills/gh-aw-report/references/search-queries.md` — Web search query library
90-
- `skills/gh-aw-report/knowledge-base.md` — Persistent knowledge base
86+
- `.claude/skills/aw-daily/SKILL.md` — Full 9-phase pipeline logic
87+
- `.claude/skills/aw-daily/references/gap-analysis-targets.md` — Reference file inventory for gap analysis
88+
- `.claude/skills/aw-daily/references/tracked-repos.md` — GitHub repos to query for activity
89+
- `.claude/skills/gh-aw-report/references/search-queries.md` — Web search query library
90+
- `.claude/skills/gh-aw-report/knowledge-base.md` — Persistent knowledge base
9191

9292
## Instructions
9393

@@ -206,9 +206,30 @@ Create a **draft** PR to `develop` using the `create-pull-request` safe-output:
206206

207207
The PR is created as a draft (frontmatter `draft: true`). The `post-steps` block automatically marks it ready for review after safe-outputs complete. Do NOT merge — merging is a separate review decision.
208208

209-
### Phase 8: Summary
209+
### Phase 8: PR Review Monitoring & Remediation
210210

211-
Report what was accomplished: searches run, findings count, gaps identified, issues created, files changed, PR URL. If any phase was skipped or failed, note it clearly.
211+
After the PR is marked ready, the `post-steps` block requests Copilot review. Monitor the PR for review feedback and remediate:
212+
213+
1. **Wait for review**: Poll `gh pr view` for review state every 30 seconds, up to 10 minutes. If `APPROVED`, skip to merge. If `CHANGES_REQUESTED`, proceed to remediation. If timeout, log and continue.
214+
215+
2. **Fetch review comments**: Use `gh api repos/{owner}/{repo}/pulls/{PR_NUMBER}/comments --paginate` to get all inline comments.
216+
217+
3. **Triage each comment**: Assess correctness and confidence. Auto-accept fixes with >= 95% confidence. Skip low-confidence fixes with an explanation reply.
218+
219+
4. **Apply fixes**: For each accepted comment, edit the target file (use section headers as anchors). If the file has a `.claude/` mirror or canonical copy, apply to both. Commit, push.
220+
221+
5. **Reply to every comment**: Fixed → `Fixed in {sha}.` Rejected → `Reviewed — not applying because {reason}.` Questions → direct answer.
222+
223+
6. **Resolve all threads**: Use GraphQL `resolveReviewThread` mutation for each thread.
224+
225+
7. **Merge the PR**: `gh pr merge {PR_NUMBER} --squash --delete-branch`. If direct merge fails (branch protection), fall back to `--auto`. Verify state is `MERGED`.
226+
227+
**Loop limit**: Maximum 2 review-fix cycles. After that, leave PR for manual review.
228+
**`--no-merge` flag**: If set, skip the merge step and report "PR left open per --no-merge flag."
229+
230+
### Phase 9: Summary
231+
232+
Report what was accomplished: searches run, findings count, gaps identified, issues created, files changed, PR URL, review status, fixes applied, threads resolved, merge state. If any phase was skipped or failed, note it clearly.
212233

213234
## Edge Cases
214235

0 commit comments

Comments
 (0)