Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/copilot-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Copilot Code Review

on:
pull_request:
types: [opened, synchronize, reopened]
pull_request_review_comment:
types: [created]

permissions:
contents: read
pull-requests: write

Comment on lines +9 to +12
jobs:
copilot-review:
# Skip draft PRs; skip when Copilot itself triggers the event to prevent infinite loops
if: |
github.event.pull_request.draft == false &&
!contains(fromJSON('["github-copilot[bot]","copilot-pull-request-reviewer[bot]"]'), github.actor)
runs-on: ubuntu-latest
steps:
- name: Dismiss previous Copilot review comments
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pullNumber = context.payload.pull_request?.number ?? context.issue.number;

const comments = await github.paginate(
github.rest.pulls.listReviewComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullNumber,
}
);

const copilotBotLogins = new Set([
'github-copilot[bot]',
'copilot-pull-request-reviewer[bot]',
]);

const copilotComments = comments.filter(
c => c.user.type === 'Bot' && copilotBotLogins.has(c.user.login)
);

for (const comment of copilotComments) {
await github.rest.pulls.deleteReviewComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}

core.info(`Dismissed ${copilotComments.length} previous Copilot review comment(s).`);

- name: Request Copilot review
# Only re-request a review on PR push/open events; Copilot re-reviews automatically
# when a user replies to one of its review comments.
if: github.event_name == 'pull_request'
continue-on-error: true
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
reviewers: ['copilot'],
});
Loading