88 notify :
99 runs-on : ubuntu-latest
1010 steps :
11- - name : Get Discord Thread ID
12- id : get_thread
13- env :
14- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
15- run : |
16- gh auth setup-git
17- THREAD_ID=""
18- COMMENTS=$(gh issue view ${{ github.event.issue.number }} --json comments --jq '.comments[].body')
19- for COMMENT in $COMMENTS; do
20- if [[ "$COMMENT" =~ <!--\ discord-thread-id:\ ([0-9]+)\ --> ]]; then
21- THREAD_ID="${BASH_REMATCH[1]}"
22- break
23- fi
24- done
25- echo "thread_id=$THREAD_ID" >> $GITHUB_OUTPUT
26-
2711 - name : Send Discord Embed
28- env :
29- DISCORD_WEBHOOK : ${{ secrets.DISCORD_WEBHOOK_ISSUES_URL }}
3012 run : |
3113 LABELS_DISPLAY="None"
3214 if [ -s "$GITHUB_EVENT_PATH" ]; then
@@ -36,48 +18,29 @@ jobs:
3618 fi
3719 fi
3820
39- if [ -z "${{ steps.get_thread.outputs.thread_id }}" ]; then
40- RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" \
41- -d "{
42- \"thread_name\": \"Issue: ${{ github.event.issue.number }} - ${{ github.event.issue.title }}\",
43- \"embeds\": [{
44- \"author\": {
45- \"name\": \"${{ github.event.issue.user.login }}\",
46- \"icon_url\": \"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"
47- },
48- \"title\": \"**Issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}**\",
49- \"description\": \"**State:** ${{ github.event.issue.state }}\",
50- \"fields\": [
51- {\"name\": \"Labels\", \"value\": \"${LABELS_DISPLAY}\", \"inline\": false},
52- {\"name\": \"View on Github\", \"value\": \"[Link](${{ github.event.issue.html_url }})\", \"inline\": false}
53- ],
54- \"color\": 3066993
55- }]
56- }" $DISCORD_WEBHOOK)
57-
58- THREAD_ID=$(echo "$RESPONSE" | jq -r '.id')
59-
60- if [ -n "$THREAD_ID" ] && [ "$THREAD_ID" != "null" ]; then
61- gh issue comment ${{ github.event.issue.number }} "<!-- discord-thread-id: $THREAD_ID -->"
62- gh issue comment ${{ github.event.issue.number }} "Your issue has been added to the community Discord."
63- fi
64- else
65- THREAD_ID="${{ steps.get_thread.outputs.thread_id }}"
66- curl -X POST -H "Content-Type: application/json" \
67- -d "{
68- \"thread_name\": \"Issue: ${{ github.event.issue.number }} - ${{ github.event.issue.title }}\",
69- \"embeds\": [{
70- \"author\": {
71- \"name\": \"${{ github.event.issue.user.login }}\",
72- \"icon_url\": \"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"
73- },
74- \"title\": \"**Issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}**\",
75- \"description\": \"**State:** ${{ github.event.issue.state }}\",
76- \"fields\": [
77- {\"name\": \"Labels\", \"value\": \"${LABELS_DISPLAY}\", \"inline\": false},
78- {\"name\": \"View on Github\", \"value\": \"[Link](${{ github.event.issue.html_url }})\", \"inline\": false}
79- ],
80- \"color\": 3066993
81- }]
82- }" "https://discord.com/api/v10/channels/$THREAD_ID/messages"
83- fi
21+ curl -X POST -H "Content-Type: application/json" \
22+ -d "{
23+ \"thread_name\": \"Issue: ${{ github.event.issue.number }} - ${{ github.event.issue.title }}\",
24+ \"embeds\": [{
25+ \"author\": {
26+ \"name\": \"${{ github.event.issue.user.login }}\",
27+ \"icon_url\": \"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"
28+ },
29+ \"title\": \"**Issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}**\",
30+ \"description\": \"**State:** ${{ github.event.issue.state }}\",
31+ \"fields\": [
32+ {
33+ \"name\": \"Labels\",
34+ \"value\": \"${LABELS_DISPLAY}\",
35+ \"inline\": false
36+ },
37+ {
38+ \"name\": \"View on Github\",
39+ \"value\": \"[Link](${{ github.event.issue.html_url }})\",
40+ \"inline\": false
41+ }
42+ ],
43+ \"color\": 3066993
44+ }]
45+ }" \
46+ ${{ secrets.DISCORD_WEBHOOK_ISSUES_URL }}
0 commit comments