feat/ #33 사진 기반 분석 #25
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Claude Code Review | |
| on: | |
| pull_request: | |
| types: [opened, synchronize] | |
| paths: | |
| - "src/**/*.java" | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| claude-review: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check skip conditions | |
| id: check-skip | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| run: | | |
| # 1. PR 제목이 chore: 또는 docs: 로 시작하면 스킵 | |
| if echo "$PR_TITLE" | grep -qiE '^(chore:|docs:)'; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "reason=PR 제목이 chore: 또는 docs: 로 시작하여 리뷰를 건너뜁니다." >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # 변경 파일 수 집계 | |
| JAVA_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '\.java$') | |
| FILE_COUNT=$(echo "$JAVA_FILES" | grep -c '\.java$' || true) | |
| # 2. 변경 Java 파일이 1개 이하면 스킵 | |
| if [ "$FILE_COUNT" -le 1 ]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "reason=변경된 Java 파일이 ${FILE_COUNT}개로 적어 리뷰를 건너뜁니다." >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # 3. 추가+삭제 라인 합계가 50줄 이하면 스킵 | |
| LINES=$(git diff --stat origin/${{ github.base_ref }}...HEAD -- '*.java' | tail -1 | grep -oE '[0-9]+ insertion' | grep -oE '[0-9]+' || echo 0) | |
| DELETIONS=$(git diff --stat origin/${{ github.base_ref }}...HEAD -- '*.java' | tail -1 | grep -oE '[0-9]+ deletion' | grep -oE '[0-9]+' || echo 0) | |
| TOTAL_LINES=$((LINES + DELETIONS)) | |
| if [ "$TOTAL_LINES" -le 50 ]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "reason=변경 라인이 ${TOTAL_LINES}줄로 50줄 이하여서 리뷰를 건너뜁니다." >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # 4. 파일이 10개 초과면 스킵 | |
| if [ "$FILE_COUNT" -gt 10 ]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "reason=변경된 파일이 ${FILE_COUNT}개로 너무 많습니다. 10개 이하로 분리하는 것을 권장합니다." >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # 모든 조건 통과 — 리뷰 실행 | |
| FILES=$(echo "$JAVA_FILES" | tr '\n' ' ') | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| echo "files=$FILES" >> $GITHUB_OUTPUT | |
| - name: Post skip comment | |
| if: steps.check-skip.outputs.skip == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr comment ${{ github.event.number }} \ | |
| --body "ℹ️ Claude 코드 리뷰 생략: ${{ steps.check-skip.outputs.reason }}" | |
| - name: Set up Node.js | |
| if: steps.check-skip.outputs.skip == 'false' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Claude Code | |
| if: steps.check-skip.outputs.skip == 'false' | |
| run: npm install -g @anthropic-ai/claude-code | |
| - name: Run Claude Review | |
| if: steps.check-skip.outputs.skip == 'false' | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CHANGED_FILES: ${{ steps.check-skip.outputs.files }} | |
| run: | | |
| mkdir -p /tmp/review | |
| claude --dangerously-skip-permissions \ | |
| -p "다음 Java 파일들을 code-reviewer 에이전트로 분석해줘. | |
| 변경된 파일 목록: | |
| $CHANGED_FILES | |
| 분석 완료 후 결과를 /tmp/review/final.md 에 저장해줘." | |
| - name: Post review comment | |
| if: steps.check-skip.outputs.skip == 'false' && always() | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [ -f /tmp/review/final.md ]; then | |
| gh pr comment ${{ github.event.number }} --body "$(cat /tmp/review/final.md)" | |
| else | |
| gh pr comment ${{ github.event.number }} --body "⚠️ Claude 리뷰 생성 중 문제가 발생했습니다. Actions 로그를 확인해 주세요." | |
| fi |