Skip to content

[BE-INFRA] 무중단 배포 be/release로 브랜치 변경 #157

[BE-INFRA] 무중단 배포 be/release로 브랜치 변경

[BE-INFRA] 무중단 배포 be/release로 브랜치 변경 #157

name: Discord Notification on PR Comment
on:
issue_comment:
types: [created, edited]
jobs:
notify-discord:
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/noti') }}
runs-on: ubuntu-latest
steps:
- name: Set Environment Variables
env:
TITLE: ${{ github.event.issue.title }}
run: |
if [[ "${{ env.TITLE }}" == *"BE"* ]]; then
echo "AVATAR_URL=${{ secrets.BE_DISCORD_AVATAR_URL }}" >> $GITHUB_ENV
echo "COMMENT_BODY= 🤚백엔드 친구들 모여라~ 🔊" >> $GITHUB_ENV
echo "USERNAME=망나뇽" >> $GITHUB_ENV
echo "WEB_HOOK=${{ secrets.BE_DISCORD_WEB_HOOK }}" >> $GITHUB_ENV
elif [[ "${{ env.TITLE }}" == *"AN"* ]]; then
echo "AVATAR_URL=${{ secrets.AN_DISCORD_AVATAR_URL }}" >> $GITHUB_ENV
echo "COMMENT_BODY= 🤖안드 친구들 모여라~ 🔊" >> $GITHUB_ENV
echo "USERNAME=이상해씨" >> $GITHUB_ENV
echo "WEB_HOOK=${{ secrets.AN_DISCORD_WEB_HOOK }}" >> $GITHUB_ENV
fi
- name: Notify Discord
env:
COMMENT_BODY: ${{ env.COMMENT_BODY }}
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
PR_URL: ${{ github.event.issue.pull_request.html_url }}
AUTHOR_URL: ${{ github.event.comment.user.avatar_url }}
AVATAR_URL: ${{ env.AVATAR_URL }}
CONTENT: ${{ github.event.comment.body }}
USERNAME: ${{ env.USERNAME }}
WEB_HOOK: ${{ env.WEB_HOOK }}
run: |
if [ -n "$WEB_HOOK" ]; then
JSON_PAYLOAD=$(jq -n \
--arg content "$CONTENT" \
--arg description "$COMMENT_BODY" \
--arg username "$USERNAME" \
--arg avatar_url "$AVATAR_URL" \
--arg title "Pull Request Command" \
--arg url "$PR_URL" \
--arg author_url "$AUTHOR_URL" \
--arg author_name "$COMMENT_AUTHOR" \
--arg color "5814783" \
--arg timestamp "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
'{
content: $content,
username: $username,
avatar_url: $avatar_url,
embeds: [{
title: $title,
url: $url,
author: {
name: $author_name,
icon_url: $author_url
},
description: $description,
color: ($color | tonumber),
timestamp: $timestamp
}]
}')
curl -X POST -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$WEB_HOOK"
else
echo "No matching title found. Skipping notification."
fi