Skip to content

리뷰 생성 시, 디스코드 알림 #887

리뷰 생성 시, 디스코드 알림

리뷰 생성 시, 디스코드 알림 #887

Workflow file for this run

name: 리뷰 생성 시, 디스코드 알림
on:
pull_request_review:
types: [submitted]
env:
hwinkr: "@해리"
Yoonkyoungme: "@빙봉"
hw0603: "@페드로"
ikjo39: "@다온"
ehBeak: "@배키"
seokmyungham: "@재즈"
Largopie: "@낙타"
seunghye218: "@마크"
jobs:
notify_changes_requested:
if: github.event_name == 'pull_request_review' && github.event.review.state == 'CHANGES_REQUESTED'
runs-on: ubuntu-latest
steps:
- name: 모든 팀원이 확인해야 하는 PR에 리뷰(CHANGES_REQUESTED)가 등록되면 FE, BE 두 채널 모두 디스코드 알림을 보낸다.
if: contains(github.event.pull_request.title, '[ALL]')
env:
FE_DISCORD_WEBHOOK_URL: ${{ secrets.FE_DISCORD_WEBHOOK_URL }}
BE_DISCORD_WEBHOOK_URL: ${{ secrets.BE_DISCORD_WEBHOOK_URL }}
run: |
REVIEWER=$(jq -r '.review.user.login' < $GITHUB_EVENT_PATH)
REVIEWER_MENTION=$(printenv $REVIEWER)
if [ -z "$REVIEWER_MENTION" ]; then
REVIEWER_MENTION=$REVIEWER
fi
REVIEWER_LINK="[${REVIEWER_MENTION}](https://github.com/${REVIEWER})"
ASSIGNEES=$(jq -r '.pull_request.assignees | map(.login) | join(" ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTIONS=""
for ASSIGNEE in $ASSIGNEES; do
MENTION=$(printenv $ASSIGNEE)
if [ -z "$MENTION" ]; then
MENTION=$ASSIGNEE
fi
ASSIGNEE_MENTIONS="${ASSIGNEE_MENTIONS}[${MENTION}](https://github.com/${ASSIGNEE}) "
done
COMMENT_BODY=$(jq -r '.review.body' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n🚨 ${REVIEWER_LINK}님이 변경을 요청했어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📂 **제목**: ${{ github.event.pull_request.title }}\n📝 **요청 내용**: ${COMMENT_BODY}\"}" \
$FE_DISCORD_WEBHOOK_URL
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n🚨 ${REVIEWER_LINK}님이 변경을 요청했어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📂 **제목**: ${{ github.event.pull_request.title }}\n📝 **요청 내용**: ${COMMENT_BODY}\"}" \
$BE_DISCORD_WEBHOOK_URLL
- name: 프론트엔드 리뷰(CHANGES_REQUESTED)가 등록되면 프론트엔드 채널에 디스코드 알림을 보낸다.
if: contains(github.event.pull_request.title, '[FE]')
env:
FE_DISCORD_WEBHOOK_URL: ${{ secrets.FE_DISCORD_WEBHOOK_URL }}
run: |
REVIEWER=$(jq -r '.review.user.login' < $GITHUB_EVENT_PATH)
REVIEWER_MENTION=$(printenv $REVIEWER)
if [ -z "$REVIEWER_MENTION" ]; then
REVIEWER_MENTION=$REVIEWER
fi
REVIEWER_LINK="[${REVIEWER_MENTION}](https://github.com/${REVIEWER})"
ASSIGNEES=$(jq -r '.pull_request.assignees | map(.login) | join(" ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTIONS=""
for ASSIGNEE in $ASSIGNEES; do
MENTION=$(printenv $ASSIGNEE)
if [ -z "$MENTION" ]; then
MENTION=$ASSIGNEE
fi
ASSIGNEE_MENTIONS="${ASSIGNEE_MENTIONS}[${MENTION}](https://github.com/${ASSIGNEE}) "
done
COMMENT_BODY=$(jq -r '.review.body' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n🚨 ${REVIEWER_LINK}님이 변경을 요청했어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📂 **제목**: ${{ github.event.pull_request.title }}\n📝 **요청 내용**: ${COMMENT_BODY}\"}" \
$FE_DISCORD_WEBHOOK_URL
- name: 백엔드 리뷰(CHANGES_REQUESTED)가 등록되면 백엔드 채널에 디스코드 알림을 보낸다.
if: contains(github.event.pull_request.title, '[BE]')
env:
BE_DISCORD_WEBHOOK_URL: ${{ secrets.BE_DISCORD_WEBHOOK_URL }}
run: |
REVIEWER=$(jq -r '.review.user.login' < $GITHUB_EVENT_PATH)
REVIEWER_MENTION=$(printenv $REVIEWER)
if [ -z "$REVIEWER_MENTION" ]; then
REVIEWER_MENTION=$REVIEWER
fi
REVIEWER_LINK="[${REVIEWER_MENTION}](https://github.com/${REVIEWER})"
ASSIGNEES=$(jq -r '.pull_request.assignees | map(.login) | join(" ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTIONS=""
for ASSIGNEE in $ASSIGNEES; do
MENTION=$(printenv $ASSIGNEE)
if [ -z "$MENTION" ]; then
MENTION=$ASSIGNEE
fi
ASSIGNEE_MENTIONS="${ASSIGNEE_MENTIONS}[${MENTION}](https://github.com/${ASSIGNEE}) "
done
COMMENT_BODY=$(jq -r '.review.body' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n🚨 ${REVIEWER_LINK}님이 변경을 요청했어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📂 **제목**: ${{ github.event.pull_request.title }}\n📝 **요청 내용**: ${COMMENT_BODY}\"}" \
$BE_DISCORD_WEBHOOK_URL
notify_commented:
if: github.event_name == 'pull_request_review' && github.event.review.state == 'COMMENTED'
runs-on: ubuntu-latest
steps:
- name: 모든 팀원이 확인해야 하는 PR에 리뷰(COMMENTED)가 등록되면 FE, BE 두 채널 모두 디스코드 알림을 보낸다.
if: contains(github.event.pull_request.title, '[ALL]')
env:
FE_DISCORD_WEBHOOK_URL: ${{ secrets.FE_DISCORD_WEBHOOK_URL }}
BE_DISCORD_WEBHOOK_URL: ${{ secrets.BE_DISCORD_WEBHOOK_URL }}
run: |
REVIEWER=$(jq -r '.review.user.login' < $GITHUB_EVENT_PATH)
REVIEWER_MENTION=$(printenv $REVIEWER)
if [ -z "$REVIEWER_MENTION" ]; then
REVIEWER_MENTION=$REVIEWER
fi
REVIEWER_LINK="[${REVIEWER_MENTION}](https://github.com/${REVIEWER})"
ASSIGNEES=$(jq -r '.pull_request.assignees | map(.login) | join(" ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTIONS=""
for ASSIGNEE in $ASSIGNEES; do
MENTION=$(printenv $ASSIGNEE)
if [ -z "$MENTION" ]; then
MENTION=$ASSIGNEE
fi
ASSIGNEE_MENTIONS="${ASSIGNEE_MENTIONS}[${MENTION}](https://github.com/${ASSIGNEE}) "
done
COMMENT_BODY=$(jq -r '.review.body' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n💬 ${REVIEWER_LINK}님이 새로운 코멘트를 남겼어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📝 **코멘트 내용**: ${COMMENT_BODY}\"}" \
$FE_DISCORD_WEBHOOK_URL
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n💬 ${REVIEWER_LINK}님이 새로운 코멘트를 남겼어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📝 **코멘트 내용**: ${COMMENT_BODY}\"}" \
$BE_DISCORD_WEBHOOK_URL
- name: 프론트엔드 리뷰(COMMENTED)가 등록되면 프론트엔드 채널에 디스코드 알림을 보낸다.
if: contains(github.event.pull_request.title, '[FE]')
env:
FE_DISCORD_WEBHOOK_URL: ${{ secrets.FE_DISCORD_WEBHOOK_URL }}
run: |
REVIEWER=$(jq -r '.review.user.login' < $GITHUB_EVENT_PATH)
REVIEWER_MENTION=$(printenv $REVIEWER)
if [ -z "$REVIEWER_MENTION" ]; then
REVIEWER_MENTION=$REVIEWER
fi
REVIEWER_LINK="[${REVIEWER_MENTION}](https://github.com/${REVIEWER})"
ASSIGNEES=$(jq -r '.pull_request.assignees | map(.login) | join(" ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTIONS=""
for ASSIGNEE in $ASSIGNEES; do
MENTION=$(printenv $ASSIGNEE)
if [ -z "$MENTION" ]; then
MENTION=$ASSIGNEE
fi
ASSIGNEE_MENTIONS="${ASSIGNEE_MENTIONS}[${MENTION}](https://github.com/${ASSIGNEE}) "
done
COMMENT_BODY=$(jq -r '.review.body' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n💬 ${REVIEWER_LINK}님이 새로운 코멘트를 남겼어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📝 **코멘트 내용**: ${COMMENT_BODY}\"}" \
$FE_DISCORD_WEBHOOK_URL
- name: 백엔드 리뷰(COMMENTED)가 등록되면 백엔드 채널에 디스코드 알림을 보낸다.
if: contains(github.event.pull_request.title, '[BE]')
env:
BE_DISCORD_WEBHOOK_URL: ${{ secrets.BE_DISCORD_WEBHOOK_URL }}
run: |
run: |
REVIEWER=$(jq -r '.review.user.login' < $GITHUB_EVENT_PATH)
REVIEWER_MENTION=$(printenv $REVIEWER)
if [ -z "$REVIEWER_MENTION" ]; then
REVIEWER_MENTION=$REVIEWER
fi
REVIEWER_LINK="[${REVIEWER_MENTION}](https://github.com/${REVIEWER})"
ASSIGNEES=$(jq -r '.pull_request.assignees | map(.login) | join(" ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTIONS=""
for ASSIGNEE in $ASSIGNEES; do
MENTION=$(printenv $ASSIGNEE)
if [ -z "$MENTION" ]; then
MENTION=$ASSIGNEE
fi
ASSIGNEE_MENTIONS="${ASSIGNEE_MENTIONS}[${MENTION}](https://github.com/${ASSIGNEE}) "
done
COMMENT_BODY=$(jq -r '.review.body' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"📱 ${ASSIGNEE_MENTIONS}\n💬 ${REVIEWER_LINK}님이 새로운 코멘트를 남겼어요!\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📝 **코멘트 내용**: ${COMMENT_BODY}\"}" \
$BE_DISCORD_WEBHOOK_URL