Skip to content

Commit 9fe53fa

Browse files
fix(ci): check unresolved Copilot threads instead of all comments
Resolved threads should not block auto-approve. Use GraphQL to count only unresolved review threads from Copilot. Co-Authored-By: Claude Opus 4.5 <[email protected]> Signed-off-by: JasonXuDeveloper - 傑 <[email protected]>
1 parent 7f9a3e1 commit 9fe53fa

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

.github/workflows/auto-approve.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,36 @@ jobs:
5252
5353
# Check Copilot review - must verify Copilot has actually reviewed first
5454
# Copilot leaves "COMMENTED" reviews (never "APPROVED" or "CHANGES_REQUESTED")
55-
# We need to: 1) Confirm a review exists, 2) Check for inline comments
56-
# Note: Copilot uses different usernames for reviews vs comments
55+
# We need to: 1) Confirm a review exists, 2) Check for UNRESOLVED comments
56+
# Note: Copilot uses "copilot-pull-request-reviewer[bot]" for reviews
5757
COPILOT_REVIEW=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" --jq '[.[] | select(.user.login == "copilot-pull-request-reviewer[bot]")] | length')
58-
COPILOT_COMMENTS=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER/comments" --jq '[.[] | select(.user.login == "Copilot")] | length')
58+
59+
# Use GraphQL to count unresolved Copilot review threads
60+
UNRESOLVED_THREADS=$(gh api graphql -f query='
61+
query($owner: String!, $repo: String!, $pr: Int!) {
62+
repository(owner: $owner, name: $repo) {
63+
pullRequest(number: $pr) {
64+
reviewThreads(first: 100) {
65+
nodes {
66+
isResolved
67+
comments(first: 1) {
68+
nodes { author { login } }
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}' -f owner="${{ github.repository_owner }}" -f repo="${{ github.event.repository.name }}" -F pr="$PR_NUMBER" \
75+
--jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false and .comments.nodes[0].author.login == "copilot-pull-request-reviewer")] | length')
5976
6077
COPILOT_OK="false"
6178
if [ "$COPILOT_REVIEW" -eq 0 ]; then
6279
echo "Copilot review: Not yet reviewed (no review found)"
63-
elif [ "$COPILOT_COMMENTS" -eq 0 ]; then
64-
echo "Copilot review: Reviewed with no issues (0 inline comments)"
80+
elif [ "$UNRESOLVED_THREADS" -eq 0 ]; then
81+
echo "Copilot review: Reviewed with no unresolved issues"
6582
COPILOT_OK="true"
6683
else
67-
echo "Copilot review: Found $COPILOT_COMMENTS inline comments - issues need addressing"
84+
echo "Copilot review: Found $UNRESOLVED_THREADS unresolved threads - issues need addressing"
6885
fi
6986
echo "Copilot OK: $COPILOT_OK"
7087

0 commit comments

Comments
 (0)