From 4d9240dab6fc69e9b9fd40e10fec2cabb1dce74e Mon Sep 17 00:00:00 2001 From: MINSEONG KIM Date: Tue, 31 Dec 2024 22:20:23 +0900 Subject: [PATCH] =?UTF-8?q?=08chore:=20PR=20=EB=A6=AC=EB=B7=B0=EC=96=B4=20?= =?UTF-8?q?=EC=84=A0=EC=A0=95=20=EC=8B=9C=20Slack=20=EC=97=B0=EB=8F=99,=20?= =?UTF-8?q?CodeRabbit=20AI=20PR=20=EB=A6=AC=EB=B7=B0=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/code-rabbit.yml | 20 +++++++++ .github/workflows/pr-reviewer.yml | 67 +++++++++++++++++++++++++++++++ .github/workflows/reviewers.json | 4 ++ 3 files changed, 91 insertions(+) create mode 100644 .github/workflows/code-rabbit.yml create mode 100644 .github/workflows/pr-reviewer.yml create mode 100644 .github/workflows/reviewers.json diff --git a/.github/workflows/code-rabbit.yml b/.github/workflows/code-rabbit.yml new file mode 100644 index 00000000..2f872b89 --- /dev/null +++ b/.github/workflows/code-rabbit.yml @@ -0,0 +1,20 @@ +name: AI-based PR Reviewer with CodeRabbit + +on: + pull_request: + types: [opened, synchronize] + +jobs: + ai_pr_reviewer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: CodeRabbit AI Review + uses: coderabbitai/ai-pr-reviewer@1.16.2 + with: + language: 'ko' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-reviewer.yml b/.github/workflows/pr-reviewer.yml new file mode 100644 index 00000000..7ced3f40 --- /dev/null +++ b/.github/workflows/pr-reviewer.yml @@ -0,0 +1,67 @@ +name: PR Reviewer Notification + +on: + pull_request: + types: [review_requested] + +jobs: + specific_review_requested: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Get Reviewers List + id: reviewers + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const workers = JSON.parse(fs.readFileSync('.github/workflows/reviewers.json')); + const mention = context.payload.pull_request.requested_reviewers.map((user) => { + const login = user.login; + const mappedValue = workers[login]; + return mappedValue ? <@${mappedValue}> : No mapping found for ${login}; + }); + return mention.join(', '); + result-encoding: string + + - name: Send Slack Notification + id: slack_notification + uses: slackapi/slack-github-action@v1.24.0 + with: + channel-id: ${{ secrets.PR_NOTI_CHANNEL }} + payload: | + { + "text": "pr review request", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "리뷰어로 할당되었습니다.\n • 제목: ${{ github.event.pull_request.title }}\n • 리뷰어: ${{ steps.reviewers.outputs.result }}\n • 링크: <${{ github.event.pull_request.html_url }}|리뷰하러 가기>" + } + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.PR_BOT_TOKEN }} + + - name: Comment on Slack Thread + uses: slackapi/slack-github-action@v1.24.0 + with: + channel-id: ${{ secrets.PR_NOTI_CHANNEL }} + payload: | + { + "text": "PR 코멘트 알림", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "| *작성자*: @${{ github.event.comment.user.login }}\n| *코멘트 내용*: _${{ github.event.comment.body }}_\n| *관련 PR*: <${{ github.event.issue.html_url }}|${{ github.event.issue.title }}>" + } + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.PR_BOT_TOKEN }} diff --git a/.github/workflows/reviewers.json b/.github/workflows/reviewers.json new file mode 100644 index 00000000..b6c6150a --- /dev/null +++ b/.github/workflows/reviewers.json @@ -0,0 +1,4 @@ +{ + "minseong0324": "U083UEXJLLC", + "kongnayeon": "U083BDHR279" +}