|
| 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