PR Reviewer Notification #5
This file contains 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: PR Reviewer Notification | |
on: | |
pull_request: | |
types: [review_requested] | |
issue_comment: | |
types: [created] | |
pull_request_review_comment: | |
types: [created] | |
jobs: | |
specific_review_requested: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Reviewers List | |
id: reviewers | |
uses: actions/github-script@v7 | |
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 }} |