Skip to content

Commit 9e81771

Browse files
authored
feat: PR이 머지된 후, 디스코드에 커스텀웹훅을 통해 챌린지 현황 조회할 수 있는 기능 추가
- 이전에는 PR에 comment로 남기는 형식이었음. 하지만 이전 형식은 충돌 문제가 존재 - 충돌 문제를 해결하기 위해 PR이 머지된 이후에 동작하도록 변경. 이에 따라 PR comment가 아닌 디스코드 웹훅 방식으로 변경 - 일반적인 웹훅 메시지가 아니라 커스텀 웹훅으로 기능 추가
1 parent 66af303 commit 9e81771

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/update_challenge_progress.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,51 @@ jobs:
6464
issue_number: prNumber,
6565
body: dashboard
6666
});
67+
68+
notify_discord:
69+
needs: update_progress
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Checkout Repository
73+
uses: actions/checkout@v3
74+
with:
75+
fetch-depth: 0
76+
ref: main
77+
78+
- name: Send Dashboard to Discord
79+
working-directory: _MonthlyChallenges
80+
run: |
81+
# DASHBOARD.md 파일을 안전하게 JSON 문자열로 이스케이프
82+
DASHBOARD_CONTENT=$(jq -R -s '.' DASHBOARD.md)
83+
echo "Dashboard content: $DASHBOARD_CONTENT"
84+
85+
# Discord 임베드 메시지 JSON 생성
86+
EMBED_JSON=$(cat <<EOF
87+
{
88+
"content": "",
89+
"embeds": [
90+
{
91+
"author": {
92+
"name": "Allumbus🔥",
93+
"url": "https://github.com/AlgorithmStudy-Allumbus",
94+
"icon_url": "https://imgur.com/kKJg6v3.jpg"
95+
},
96+
"title": "**📊 챌린지 진행 상황**",
97+
"url": "https://github.com/AlgorithmStudy-Allumbus/codingtest_algorithm_study/blob/main/_MonthlyChallenges/DASHBOARD.md",
98+
"description": ${DASHBOARD_CONTENT},
99+
"color": 15258703,
100+
"footer": {
101+
"text": "Updated on $(date '+%Y-%m-%d %H:%M:%S')"
102+
}
103+
}
104+
]
105+
}
106+
EOF
107+
)
108+
echo "Embed JSON: $EMBED_JSON"
109+
110+
# Discord 웹훅 호출 (디버그를 위해 -v 옵션 사용)
111+
curl -v -H "Content-Type: application/json" \
112+
-X POST \
113+
-d "$EMBED_JSON" \
114+
"${{ secrets.DISCORD_WEBHOOK_URL }}"

0 commit comments

Comments
 (0)