Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: "Claude Code Review"

on:
pull_request:
types: [ opened, reopened, synchronize ]

concurrency:
group: claude-review-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
review:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -48,14 +54,17 @@ jobs:
author {
login
}
reactions {
totalCount
}
}
}
}
}
}
}
}' \
--jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | select([.comments.nodes[].author.login] | all(. == "github-actions")) | .comments.nodes[].databaseId' \
--jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | select([.comments.nodes[].author.login] | all(. == "github-actions")) | select([.comments.nodes[].reactions.totalCount] | add == 0) | .comments.nodes[].databaseId' \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[확인 필요] add == 0 조건은 스레드 단위로 동작합니다

현재 필터는 스레드 내 모든 코멘트의 리액션 합계가 0인 경우에만 삭제합니다. 즉, 스레드 안에서 어느 코멘트 하나라도 리액션이 달리면 스레드 전체가 보존됩니다.

  • 이것이 의도라면 (스레드 단위 보존): 현재 로직이 정확합니다. ✅
  • 코멘트 단위로 보존하고 싶다면: jq 파이프라인을 코멘트 레벨로 분리해야 합니다.

의도한 동작임을 명확히 하기 위해 PR 설명이나 주석으로 "스레드 단위 보존" 정책을 명시하는 것을 권장합니다.

| while read comment_id; do
if [ -n "$comment_id" ]; then
echo "🗑️ 인라인 코멘트 삭제: $comment_id"
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/comment-response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Claude Issue & PR Comment Response

on:
issue_comment:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[버그] issue_comment 이벤트는 일반 이슈에서도 발생합니다

issue_comment 트리거는 PR뿐 아니라 일반 이슈의 코멘트에서도 발동됩니다. PR 전용으로 제한하려면 if 조건에 PR 컨텍스트 체크를 추가해야 합니다.

if: |
  github.event.comment.user.login != 'github-actions[bot]' &&
  contains(github.event.comment.body, '@claude') &&
  (github.event_name == 'pull_request_review_comment' || github.event.issue.pull_request != null)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이슈에서도 사용 가능하도록 유연하게 설정하기 위한 의도였음.

types: [ created ]
pull_request_review_comment:
types: [ created ]

concurrency:
group: claude-comment-${{ github.event.issue.number }}-${{ github.event.comment.id }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[버그] pull_request_review_comment 이벤트에서 concurrency group 키가 불완전합니다.

github.event.issue.numberpull_request_review_comment 이벤트에서 null이 됩니다. comment.id가 전역 고유값이라 실제 충돌 가능성은 낮지만, 디버깅 시 group 키가 claude-comment-null-<id> 형태로 보여 혼란을 줄 수 있습니다.

Suggested change
group: claude-comment-${{ github.event.issue.number }}-${{ github.event.comment.id }}
group: claude-comment-${{ github.event.issue.number || github.event.pull_request.number }}-${{ github.event.comment.id }}

cancel-in-progress: false

jobs:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[개선] concurrency 설정 누락

code-review.yml과 달리 이 워크플로우에는 concurrency 설정이 없습니다. 짧은 시간에 여러 번 @claude를 멘션하면 다수의 Claude 인스턴스가 동시에 실행될 수 있습니다.

jobs: 블록 앞에 추가하는 것을 권장합니다:

concurrency:
  group: claude-comment-${{ github.event.issue.number }}-${{ github.event.comment.id }}
  cancel-in-progress: false

코멘트 응답은 각각 독립적으로 처리되어야 하므로 cancel-in-progress: false가 적합합니다.

respond:
if: |
github.event.comment.user.login != 'github-actions[bot]' &&
contains(github.event.comment.body, '@claude') &&
(github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR')
Comment on lines +15 to +20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[제안] author_association 제한 범위 문서화 권장

현재 MEMBER, OWNER, COLLABORATOR@claude를 호출할 수 있어 외부 기여자(CONTRIBUTOR, FIRST_TIME_CONTRIBUTOR 등)는 사용할 수 없습니다. 의도된 보안 정책이라면 팀 문서나 PR 설명에 명시하는 것을 권장합니다.

또한 github.event.comment.user.login 대신 github.actor를 사용하면 이벤트 타입에 관계없이 일관되게 동작합니다.

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@v1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[보안] claude-code-action 허용 툴 범위 미설정

allowed_tools 없이 실행하면 Claude가 git push, 파일 삭제 등 광범위한 작업을 수행할 수 있습니다. 의도한 사용 범위에 맞게 툴을 제한하는 것을 권장합니다.

Suggested change
- uses: anthropics/claude-code-action@v1
- uses: anthropics/claude-code-action@v1
        with:
          claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
          allowed_tools: "Bash,Read,Write,Edit"  # 필요한 툴만 허용

최소 권한 원칙(Principle of Least Privilege) 적용을 위해 실제 사용 패턴을 확인 후 범위를 좁히는 것을 추천합니다.

with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
Loading