-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (78 loc) · 3.38 KB
/
code-review.yml
File metadata and controls
78 lines (78 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: "Claude Code Review"
on:
pull_request:
types: [ opened, reopened, synchronize ]
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Delete Previous Claude Reviews
if: github.event.action == 'synchronize'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set +e # Continue on error
PR_NUMBER=${{ github.event.pull_request.number }}
REPO=${{ github.repository }}
echo "🔍 이전 Claude 리뷰 검색 중..."
# 1. PR 코멘트(요약) 삭제 - github-actions[bot]이 작성한 코멘트
gh api "repos/$REPO/issues/$PR_NUMBER/comments" \
--jq '.[] | select(.user.login == "github-actions[bot]") | .id' \
| while read comment_id; do
if [ -n "$comment_id" ]; then
echo "🗑️ PR 코멘트 삭제: $comment_id"
gh api -X DELETE "repos/$REPO/issues/comments/$comment_id" 2>/dev/null || echo "⚠️ 삭제 실패 (무시)"
sleep 0.3
fi
done
# 2. 인라인 리뷰 코멘트 삭제
# - 미해결 스레드 중 bot 코멘트만 있는 스레드만 삭제
# - 사용자 답글이 있는 스레드는 삭제하지 않음 (코드만 덩그러니 남는 문제 방지)
OWNER=${REPO%/*}
NAME=${REPO#*/}
gh api graphql -F owner="$OWNER" -F name="$NAME" -F number=$PR_NUMBER -f query='
query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
reviewThreads(last: 100) {
nodes {
isResolved
comments(first: 50) {
nodes {
databaseId
author {
login
}
}
}
}
}
}
}
}' \
--jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | select([.comments.nodes[].author.login] | all(. == "github-actions")) | .comments.nodes[].databaseId' \
| while read comment_id; do
if [ -n "$comment_id" ]; then
echo "🗑️ 인라인 코멘트 삭제: $comment_id"
gh api -X DELETE "repos/$REPO/pulls/comments/$comment_id" 2>/dev/null || echo "⚠️ 삭제 실패 (무시)"
sleep 0.3
fi
done
echo "✅ 이전 리뷰 삭제 완료"
- name: Run Claude Code Review
uses: anthropics/claude-code-action@v1
with:
show_full_output: true
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
이 PR을 리뷰하고 코멘트로 작성해주세요.
claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"