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, reopened] | |
| branches: | |
| - main | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| review: | |
| runs-on: ubuntu-latest | |
| # PR ์ฝ๋ฉํธ ํธ๋ฆฌ๊ฑฐ์ผ ๋ /review ๋๊ธ + PR์์๋ง ์คํ | |
| if: | | |
| github.event_name == 'pull_request' || | |
| (github.event_name == 'issue_comment' && | |
| github.event.issue.pull_request && | |
| github.event.comment.body == '/review') | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get PR number | |
| id: pr | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT | |
| echo "base=${{ github.event.pull_request.base.sha }}" >> $GITHUB_OUTPUT | |
| echo "head=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT | |
| else | |
| PR_DATA=$(gh pr view ${{ github.event.issue.number }} --json number,baseRefOid,headRefOid) | |
| echo "number=$(echo $PR_DATA | jq -r '.number')" >> $GITHUB_OUTPUT | |
| echo "base=$(echo $PR_DATA | jq -r '.baseRefOid')" >> $GITHUB_OUTPUT | |
| echo "head=$(echo $PR_DATA | jq -r '.headRefOid')" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get diff | |
| run: | | |
| git diff ${{ steps.pr.outputs.base }} ${{ steps.pr.outputs.head }} > pr_diff.txt | |
| echo "Diff size: $(wc -c < pr_diff.txt) bytes" | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: pip install anthropic | |
| - name: Run Claude Review | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| run: python .github/scripts/claude_review.py | |
| - name: Post Review Comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const review = fs.readFileSync('review_result.txt', 'utf8'); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: ${{ steps.pr.outputs.number }}, | |
| body: review | |
| }); |