-
Notifications
You must be signed in to change notification settings - Fork 0
코드 리뷰 actions 스크립트 추가 #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,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 }} | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [보안] 스크립트 인젝션 취약점
Suggested change
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER_ENV: ${{ github.event.pull_request.number }}
REPO_ENV: ${{ github.repository }} |
||||||||
| 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) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [제한] GraphQL 페이지네이션 미처리
필요하다면 |
||||||||
| 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' \ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [버그] bot 로그인 식별자 불일치 25번째 줄에서는
GraphQL에서 실제 반환값을 확인하고 일치시켜야 합니다.
Suggested change
|
||||||||
| | 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 | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [보안] 액션 버전 고정 권장
Suggested change
SHA는 사용 시점의 최신 |
||||||||
| 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:*)" | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[개선]
concurrency설정 누락synchronize이벤트가 짧은 간격으로 여러 번 발생하면(빠른 연속 커밋) 여러 워크플로우가 동시에 실행될 수 있습니다. 이 경우 삭제 → 리뷰 생성 단계가 서로 경쟁하여 예상치 못한 동작이 발생할 수 있습니다.concurrency설정을 추가하면 동일 PR에 대한 이전 실행을 자동으로 취소할 수 있습니다:(들여쓰기 없이
jobs:와 같은 레벨에 위치해야 합니다.)