From 851a19309d39482def754d305989f31a1d30b4e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:03:12 +0000 Subject: [PATCH 1/3] Initial plan From 908e67ea1dd703742273ef5140d6d163e632af9b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:10:48 +0000 Subject: [PATCH 2/3] Add Copilot review workflow with duplicate comment prevention Co-authored-by: halotukozak <64359735+halotukozak@users.noreply.github.com> --- .github/workflows/copilot-review.yml | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/copilot-review.yml diff --git a/.github/workflows/copilot-review.yml b/.github/workflows/copilot-review.yml new file mode 100644 index 00000000..0bcea74c --- /dev/null +++ b/.github/workflows/copilot-review.yml @@ -0,0 +1,62 @@ +name: Copilot Code Review + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +jobs: + copilot-review: + if: github.event.pull_request.draft == false + 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; + + 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 + 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'], + }); From f1fe69c1ef966c767f5ccc734b46dd6beb281c63 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:21:19 +0000 Subject: [PATCH 3/3] Also clean up Copilot comments when user replies to review comments Co-authored-by: halotukozak <64359735+halotukozak@users.noreply.github.com> --- .github/workflows/copilot-review.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copilot-review.yml b/.github/workflows/copilot-review.yml index 0bcea74c..6ce43ede 100644 --- a/.github/workflows/copilot-review.yml +++ b/.github/workflows/copilot-review.yml @@ -3,6 +3,8 @@ name: Copilot Code Review on: pull_request: types: [opened, synchronize, reopened] + pull_request_review_comment: + types: [created] permissions: contents: read @@ -10,7 +12,10 @@ permissions: jobs: copilot-review: - if: github.event.pull_request.draft == false + # 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 @@ -18,7 +23,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const pullNumber = context.payload.pull_request.number; + const pullNumber = context.payload.pull_request?.number ?? context.issue.number; const comments = await github.paginate( github.rest.pulls.listReviewComments, @@ -49,6 +54,9 @@ jobs: 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: