From 2226f89e28297600f2162d04da56228193306076 Mon Sep 17 00:00:00 2001 From: Soim Kim Date: Fri, 13 Feb 2026 10:03:13 +0900 Subject: [PATCH] Add pr-review job to pull-request workflow Co-authored-by: Cursor --- .github/workflows/pull-request.yml | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 351e964..be69ff9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -62,3 +62,59 @@ jobs: - uses: actions/checkout@v3 - name: REUSE Compliance Check uses: fsfe/reuse-action@v1 + + pr-review: + runs-on: ubuntu-latest + continue-on-error: true + permissions: + contents: read + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get diff + id: diff + run: | + git diff "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" -- . > diff.txt + echo "size=$(wc -c < diff.txt)" >> $GITHUB_OUTPUT + - name: Skip if no code change + id: skip + run: | + if [ "${{ steps.diff.outputs.size }}" -lt 5 ]; then + echo "skip=true" >> $GITHUB_OUTPUT + else + echo "skip=false" >> $GITHUB_OUTPUT + fi + - name: Request review from service + id: review + if: steps.skip.outputs.skip != 'true' + env: + SERVICE_URL: ${{ secrets.PR_REVIEW_SERVICE_URL }} + run: | + echo '{"pr_title": ${{ toJSON(github.event.pull_request.title) }}, "pr_body": ${{ toJSON(github.event.pull_request.body) }}}' > meta.json + jq -n --rawfile diff diff.txt --slurpfile m meta.json '$m[0] + {diff: $diff}' > payload.json + BODY=$(curl -sf --max-time 660 -X POST "${SERVICE_URL}/review" \ + -H "Content-Type: application/json" \ + -d @payload.json \ + | jq -r .body) || true + echo "## πŸ€– LLM 리뷰 μš”μ•½" > review_body.md + echo "" >> review_body.md + echo "${BODY:-리뷰 생성에 μ‹€νŒ¨ν–ˆκ±°λ‚˜ 응닡이 λΉ„μ–΄ μžˆμŠ΅λ‹ˆλ‹€.}" >> review_body.md + - name: Post review comment + if: steps.skip.outputs.skip != 'true' && success() + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.TOKEN || secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body-path: review_body.md + edit-mode: replace + - name: Comment when no code change + if: steps.skip.outputs.skip == 'true' + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.TOKEN || secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: "## πŸ€– LLM 리뷰 μš”μ•½\n\n이 PRμ—λŠ” 리뷰할 μ½”λ“œ 변경이 μ—†μŠ΅λ‹ˆλ‹€." + edit-mode: replace