-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (60 loc) · 2.23 KB
/
Issue_Noti.yml
File metadata and controls
66 lines (60 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Discord notification on new issues
on:
issues:
types: [opened, reopened]
workflow_dispatch:
jobs:
notify-discord-issue:
runs-on: ubuntu-latest
steps:
- name: Debug All Event Data
run: echo '${{ toJson(github.event) }}'
- name: Set Environment Variables
env:
TITLE: ${{ github.event.issue.title }}
run: |
echo "AVATAR_URL=${{ secrets.DISCORD_AVATAR_URL }}" >> $GITHUB_ENV
echo "USERNAME=낭만고앵이" >> $GITHUB_ENV
echo "CONTENT=새 이슈가 생겼어요!" >> $GITHUB_ENV
echo "WEB_HOOK=${{ secrets.DISCORD_WEB_HOOK }}" >> $GITHUB_ENV
- name: Notify Discord
env:
AUTHOR_NAME: ${{ github.event.issue.user.login }}
ISSUE_URL: ${{ github.event.issue.html_url }}
ISSUE_TITLE: ${{ github.event.issue.title }}
AUTHOR_URL: ${{ github.event.issue.user.avatar_url }}
AVATAR_URL: ${{ env.AVATAR_URL }}
USERNAME: ${{ env.USERNAME }}
WEB_HOOK: ${{ env.WEB_HOOK }}
CONTENT: ${{ env.CONTENT }}
run: |
if [ -n "$WEB_HOOK" ]; then
JSON_PAYLOAD=$(jq -n \
--arg content "$CONTENT" \
--arg username "$USERNAME" \
--arg avatar_url "$AVATAR_URL" \
--arg issue_title "$ISSUE_TITLE" \
--arg issue_url "$ISSUE_URL" \
--arg author_url "$AUTHOR_URL" \
--arg author_name "$AUTHOR_NAME" \
--arg color "5814783" \
--arg timestamp "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
'{
username: $username,
avatar_url: $avatar_url,
content: $content,
embeds: [{
title: $issue_title,
url: $issue_url,
author: {
name: $author_name,
icon_url: $author_url
},
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