Skip to content

Commit

Permalink
chore: PR 작성 시 슬랙 알림 봇 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jsk3342 committed Nov 12, 2024
1 parent d04b676 commit b981254
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/reviewers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repositories:
dev-fe:
reviewers:
- githubName: jsk3342
slackId: U07GSBHPCPR
name: 김지수
- githubName: gominzip
slackId: U07H6QLFPBM
name: 고민지
- githubName: spearStr
slackId: U07H9CTPC9J
name: 홍창현

dev-be:
reviewers:
- githubName: hoeeeeeh
slackId: U07GSBPT9ST
name: 김영길
- githubName: i3kae
slackId: U07H0978N14
name: 김준서
79 changes: 79 additions & 0 deletions .github/workflows/pr-slack-notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# .github/workflows/pr-slack-notify.yml
name: PR Slack Notification

on:
pull_request:
types: [opened, reopened]

jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# 리뷰어 정보를 JSON으로 저장
- name: Set reviewers based on repository
id: set-reviewers
run: |
REPO_NAME="${{ github.repository }}"
if [[ $REPO_NAME == */dev-fe ]]; then
echo "team=FE" >> $GITHUB_OUTPUT
echo "reviewers=<@U07GSBHPCPR> <@U07H6QLFPBM> <@U07H9CTPC9J>" >> $GITHUB_OUTPUT
elif [[ $REPO_NAME == */dev-be ]]; then
echo "team=BE" >> $GITHUB_OUTPUT
echo "reviewers=<@U07GSBPT9ST> <@U07H0978N14>" >> $GITHUB_OUTPUT
fi
- name: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "🔍 *새로운 ${{ steps.set-reviewers.outputs.team }} PR이 등록되었습니다*"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repository:*\n${{ github.repository }}"
},
{
"type": "mrkdwn",
"text": "*작성자:*\n<@${{ github.event.pull_request.user.login }}>"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*PR 제목:*\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*PR 설명:*\n${{ github.event.pull_request.body }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "👉 ${{ steps.set-reviewers.outputs.reviewers }} 리뷰 부탁드립니다!"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit b981254

Please sign in to comment.