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" +}