Skip to content

Commit 6badddd

Browse files
committed
request copilot review only once per pull request instead of on every push
1 parent 7234d55 commit 6badddd

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

.github/workflows/pull_requests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,16 @@ jobs:
332332
GH_REPOSITORY: ${{ github.repository }}
333333
PR_NUMBER: ${{ github.event.pull_request.number }}
334334
run: |
335+
# Request Copilot at most once per PR. It is removed from requested_reviewers once
336+
# it finishes, so a pending-request check alone would re-request on every push.
337+
# Skip if Copilot has already submitted a review (diminishing returns on re-reviews);
338+
# a maintainer can still manually re-request from the PR UI when needed.
339+
reviewed=$(gh api "/repos/${GH_REPOSITORY}/pulls/${PR_NUMBER}/reviews" --paginate \
340+
--jq '.[].user.login')
341+
if echo "$reviewed" | grep -q 'copilot-pull-request-reviewer'; then
342+
echo 'Copilot has already reviewed this PR; not requesting again.'
343+
exit 0
344+
fi
335345
existing=$(gh api "/repos/${GH_REPOSITORY}/pulls/${PR_NUMBER}/requested_reviewers" --jq '.users[].login')
336346
if echo "$existing" | grep -q 'copilot-pull-request-reviewer'; then
337347
echo 'Copilot review already requested.'

0 commit comments

Comments
 (0)