Skip to content

Commit 1d6d18e

Browse files
rtibblesbotclaude
andcommitted
feat: add resolve_bot_pr_threads reusable workflow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent cdfc992 commit 1d6d18e

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Resolve bot PR review threads
2+
on:
3+
workflow_call:
4+
jobs:
5+
resolve-addressed-review-threads:
6+
name: Resolve addressed review threads
7+
if: >
8+
github.event_name == 'pull_request_review_comment' && github.event.comment.user.login == 'rtibblesbot' && contains(github.event.comment.body, '<!-- agent:thread-resolved -->')
9+
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- name: Resolve the thread containing this comment
16+
env:
17+
GH_TOKEN: "${{ github.token }}"
18+
OWNER: "${{ github.event.repository.owner.login }}"
19+
NAME: "${{ github.event.repository.name }}"
20+
PR: "${{ github.event.pull_request.number }}"
21+
COMMENT_ID: "${{ github.event.comment.id }}"
22+
run: |
23+
set -euo pipefail
24+
thread_id=$(gh api graphql \
25+
-f query="query(\$owner:String!,\$name:String!,\$pr:Int!){
26+
repository(owner:\$owner,name:\$name){
27+
pullRequest(number:\$pr){
28+
reviewThreads(first:100){
29+
nodes{ id isResolved comments(first:1){ nodes{ databaseId } } }
30+
}
31+
}
32+
}
33+
}" \
34+
-F owner="$OWNER" -F name="$NAME" -F pr="$PR" \
35+
--jq ".data.repository.pullRequest.reviewThreads.nodes[]
36+
| select(.isResolved==false)
37+
| select(.comments.nodes[0].databaseId==$COMMENT_ID) | .id")
38+
if [ -z "$thread_id" ]; then
39+
echo "No matching unresolved thread for comment $COMMENT_ID"; exit 0
40+
fi
41+
gh api graphql \
42+
-f query="mutation(\$id:ID!){ resolveReviewThread(input:{threadId:\$id}){ thread{ id isResolved } } }" \
43+
-f id="$thread_id"
44+
echo "Resolved thread $thread_id"

0 commit comments

Comments
 (0)