Skip to content

Commit

Permalink
chore: [ALL] issue, pr, review에도 디스코드 알림을 보낼 수 있는 설정 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hwinkr committed Jul 30, 2024
1 parent 5379fe5 commit b3f85dc
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/discord-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 전체 이슈가 등록되면 FE, BE 두 채널 모두 디스코드 알림을 보낸다.
if: github.event.issue && contains(github.event.issue.title, '[ALL]')
env:
FE_DISCORD_WEBHOOK_URL: ${{ secrets.FE_DISCORD_WEBHOOK_URL }}
BE_DISCORD_WEBHOOK_URL: ${{ secrets.BE_DISCORD_WEBHOOK_URL }}
run: |
LABELS=$(jq -r '.issue.labels | map(.name) | join(", ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_LINKS=$(jq -r '.issue.assignees | map("[\(.login)](https://github.com/\(.login))") | join(", ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTIONS=$(jq -r '.issue.assignees | map(env[.login] // .login) | join(", ")' < $GITHUB_EVENT_PATH)
ASSIGNEE_MENTION_LINKS=$(jq -r '.issue.assignees | map("[\((env[.login] // .login))](https://github.com/\(.login))") | join(", ")' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"🍀 **새로운 전체 이슈가 등록되었어요!** 🧚: ${{ github.event.issue.html_url }}\n📂 **제목**: ${{ github.event.issue.title }}\n🕺 **담당 크루**: ${ASSIGNEE_MENTION_LINKS}\n🗝️ **업무 키워드**: ${LABELS}\"}" \
$FE_DISCORD_WEBHOOK_URL
curl -H "Content-Type: application/json" \
-d "{\"content\": \"🍀 **새로운 전체 이슈가 등록되었어요!** 🧚: ${{ github.event.issue.html_url }}\n📂 **제목**: ${{ github.event.issue.title }}\n🕺 **담당 크루**: ${ASSIGNEE_MENTION_LINKS}\n🗝️ **업무 키워드**: ${LABELS}\"}" \
$BE_DISCORD_WEBHOOK_URL
- name: 새로운 프론트엔드 이슈가 등록되면 프론트엔드 채널에 디스코드 알림을 보낸다.
if: github.event.issue && contains(github.event.issue.title, '[FE]')
env:
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/discord-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 모든 팀원이 확인해야 하는 PR이 등록되면 FE, BE 두 채널 모두 디스코드 알림을 보낸다.
if: github.event_name == 'pull_request' && github.event.action == 'opened' && 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: |
ASSIGNEES=$(jq -r '.pull_request.assignees | map("[\(.login)](https://github.com/\(.login))") | join(", ")' < $GITHUB_EVENT_PATH)
LABELS=$(jq -r '.pull_request.labels | map(.name) | join(", ")' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"🚀 **새로운 전체 PR이 등록되었어요!** 리뷰하러 가볼까요~?\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n🕺 **담당 크루**: ${ASSIGNEES}\n🔑 **업무 키워드**: ${LABELS}\"}" \
$FE_DISCORD_WEBHOOK_URL
curl -H "Content-Type: application/json" \
-d "{\"content\": \"🚀 **새로운 전체 PR이 등록되었어요!** 리뷰하러 가볼까요~?\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n🕺 **담당 크루**: ${ASSIGNEES}\n🔑 **업무 키워드**: ${LABELS}\"}" \
$BE_DISCORD_WEBHOOK_URL
- name: 새로운 프론트엔드 PR이 등록되면 프론트엔드 채널에 디스코드 알림을 보낸다.
if: github.event_name == 'pull_request' && github.event.action == 'opened' && contains(github.event.pull_request.title, '[FE]')
env:
Expand All @@ -27,7 +42,7 @@ jobs:
ASSIGNEES=$(jq -r '.pull_request.assignees | map("[\(.login)](https://github.com/\(.login))") | join(", ")' < $GITHUB_EVENT_PATH)
LABELS=$(jq -r '.pull_request.labels | map(.name) | join(", ")' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"🚀 **새로운 프론트엔드 PR이 등록되었어요!** 리뷰하러 가볼까요~?\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n🕺 **담당 크루**: ${ASSIGNEES}\n🏷️ **라벨**: ${LABELS}\"}" \
-d "{\"content\": \"🚀 **새로운 프론트엔드 PR이 등록되었어요!** 리뷰하러 가볼까요~?\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n🕺 **담당 크루**: ${ASSIGNEES}\n🔑 **업무 키워드**: ${LABELS}\"}" \
$FE_DISCORD_WEBHOOK_URL
- name: 새로운 백엔드 PR이 등록되면 프론트엔드 채널에 디스코드 알림을 보낸다.
Expand All @@ -38,7 +53,7 @@ jobs:
ASSIGNEES=$(jq -r '.pull_request.assignees | map("[\(.login)](https://github.com/\(.login))") | join(", ")' < $GITHUB_EVENT_PATH)
LABELS=$(jq -r '.pull_request.labels | map(.name) | join(", ")' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"🚀 **새로운 백엔드 PR이 등록되었어요!** 리뷰하러 가볼까요~?\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n🕺 **담당 크루**: ${ASSIGNEES}\n🏷️ **라벨**: ${LABELS}\"}" \
-d "{\"content\": \"🚀 **새로운 백엔드 PR이 등록되었어요!** 리뷰하러 가볼까요~?\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n🕺 **담당 크루**: ${ASSIGNEES}\n🔑 **업무 키워드**: ${LABELS}\"}" \
$BE_DISCORD_WEBHOOK_URL
notify_merge:
Expand All @@ -54,8 +69,8 @@ jobs:
ASSIGNEES=$(jq -r '.pull_request.assignees | map("[\(.login)](https://github.com/\(.login))") | join(", ")' < $GITHUB_EVENT_PATH)
LABELS=$(jq -r '.pull_request.labels | map(.name) | join(", ")' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"✅ **PR이 머지되었어요!** 축하합니다~ 👏\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📜 🕺 **담당 크루**: ${ASSIGNEES}\n🏷️ **라벨**: ${LABELS}\"}" \
-d "{\"content\": \"✅ **PR이 머지되었어요!** 축하합니다~ 👏\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📜 🕺 **담당 크루**: ${ASSIGNEES}\n🔑 **업무 키워드**: ${LABELS}\"}" \
$FE_DISCORD_WEBHOOK_URL
curl -H "Content-Type: application/json" \
-d "{\"content\": \"✅ **PR이 머지되었어요!** 축하합니다~ 👏\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📜 🕺 **담당 크루**: ${ASSIGNEES}\n🏷️ **라벨**: ${LABELS}\"}" \
-d "{\"content\": \"✅ **PR이 머지되었어요!** 축하합니다~ 👏\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\n📜 🕺 **담당 크루**: ${ASSIGNEES}\n🔑 **업무 키워드**: ${LABELS}\"}" \
$BE_DISCORD_WEBHOOK_URL
39 changes: 39 additions & 0 deletions .github/workflows/discord-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 모든 팀원이 확인해야 하는 PR에 리뷰가 등록되면 FE, BE 두 채널 모두 디스코드 알림을 보낸다.
if: github.event_name == 'pull_request_review' && 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})"
curl -H "Content-Type: application/json" \
-d "{\"content\": \"💬 ${REVIEWER_LINK}님이 새로운 리뷰를 남겼어요! 리뷰를 반영해 주세요.\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\"}" \
$FE_DISCORD_WEBHOOK_URL
curl -H "Content-Type: application/json" \
-d "{\"content\": \"💬 ${REVIEWER_LINK}님이 새로운 리뷰를 남겼어요! 리뷰를 반영해 주세요.\n\n🔗 [PR 링크](${{ github.event.pull_request.html_url }})\n📄 **제목**: ${{ github.event.pull_request.title }}\"}" \
$BE_DISCORD_WEBHOOK_URL
- name: 새로운 프론트엔드 리뷰가 등록되면 프론트엔드 채널에 디스코드 알림을 보낸다.
if: github.event_name == 'pull_request_review' && contains(github.event.pull_request.title, '[FE]')
env:
Expand Down Expand Up @@ -55,6 +74,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 모든 팀원이 확인해야 하는 PR에 코멘트가 등록되면 FE, BE 두 채널 모두 디스코드 알림을 보낸다.
if: github.event.issue.pull_request && contains(github.event.issue.title, '[ALL]')
env:
FE_DISCORD_WEBHOOK_URL: ${{ secrets.FE_DISCORD_WEBHOOK_URL }}
BE_DISCORD_WEBHOOK_URL: ${{ secrets.BE_DISCORD_WEBHOOK_URL }}
run: |
COMMENTER=$(jq -r '.comment.user.login' < $GITHUB_EVENT_PATH)
COMMENTER_MENTION=$(printenv $COMMENTER)
if [ -z "$COMMENTER_MENTION" ]; then
COMMENTER_MENTION=$COMMENTER
fi
COMMENTER_LINK="[${COMMENTER_MENTION}](https://github.com/${COMMENTER})"
COMMENT=$(jq -r '.comment.body' < $GITHUB_EVENT_PATH)
curl -H "Content-Type: application/json" \
-d "{\"content\": \"💬 ${COMMENTER_LINK}님이 새로운 코멘트를 남겼어요!\n\n🔗 [PR 링크](${{ github.event.issue.pull_request.html_url }})\n📄 **제목**: ${{ github.event.issue.title }}\n🗣️ **코멘트 내용**: ${COMMENT}\"}" \
$FE_DISCORD_WEBHOOK_URL
curl -H "Content-Type: application/json" \
-d "{\"content\": \"💬 ${COMMENTER_LINK}님이 새로운 코멘트를 남겼어요!\n\n🔗 [PR 링크](${{ github.event.issue.pull_request.html_url }})\n📄 **제목**: ${{ github.event.issue.title }}\n🗣️ **코멘트 내용**: ${COMMENT}\"}" \
$BE_DISCORD_WEBHOOK_URL
- name: 프론트엔드 PR에 코멘트가 등록되면 디스코드 프론트엔드 채널에 알림을 보낸다.
if: github.event.issue.pull_request && contains(github.event.issue.title, '[FE]')
env:
Expand Down

0 comments on commit b3f85dc

Please sign in to comment.