Skip to content

Commit b68913a

Browse files
committed
ci: add wait-for-copilot poller + copilot review notify comment
1 parent 0639065 commit b68913a

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: copilot-review-notify
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
jobs:
8+
comment:
9+
if: github.event.review.user.login == 'github-copilot[bot]'
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
13+
contents: read
14+
steps:
15+
- name: Add comment noting Copilot review
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
const owner = context.repo.owner;
20+
const repo = context.repo.repo;
21+
const number = context.payload.pull_request.number;
22+
const url = context.payload.pull_request.html_url;
23+
await github.rest.issues.createComment({
24+
owner,
25+
repo,
26+
issue_number: number,
27+
body: `Automated: GitHub Copilot has submitted a review for ${url}.`
28+
});
29+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: wait-for-copilot
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
wait:
9+
name: Wait for Copilot review
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: read
13+
contents: read
14+
concurrency:
15+
group: wait-for-copilot-${{ github.event.pull_request.number }}
16+
cancel-in-progress: true
17+
steps:
18+
- name: Poll for Copilot review (max 15m)
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const pr = context.payload.pull_request;
23+
const owner = context.repo.owner;
24+
const repo = context.repo.repo;
25+
const number = pr.number;
26+
const deadline = Date.now() + 15 * 60 * 1000; // 15 minutes
27+
const botLogin = 'github-copilot[bot]';
28+
29+
async function hasCopilotFeedback() {
30+
const [reviews, comments] = await Promise.all([
31+
github.rest.pulls.listReviews({ owner, repo, pull_number: number, per_page: 100 }),
32+
github.rest.issues.listComments({ owner, repo, issue_number: number, per_page: 100 }),
33+
]);
34+
const anyReview = reviews.data.some(r => (r.user?.login || '') === botLogin);
35+
const anyComment = comments.data.some(c => (c.user?.login || '') === botLogin);
36+
core.info(`Copilot review detected: ${anyReview}, comment detected: ${anyComment}`);
37+
return anyReview || anyComment;
38+
}
39+
40+
while (Date.now() < deadline) {
41+
if (await hasCopilotFeedback()) {
42+
core.notice('Copilot review found.');
43+
return;
44+
}
45+
await new Promise(r => setTimeout(r, 20_000));
46+
}
47+
core.setFailed('Copilot review not found within 15 minutes.');
48+

0 commit comments

Comments
 (0)