Skip to content

Commit 9a28a4d

Browse files
committed
feat(notify-discord-issues): enhance Discord webhook payload creation to support multiple trigger types and improve data handling for issue details
1 parent 3ec2d36 commit 9a28a4d

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

.github/workflows/notify-discord-issues.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,28 +74,49 @@ jobs:
7474
7575
- name: Create Discord webhook payload
7676
run: |
77+
# Determine data source based on trigger type
78+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
79+
ISSUE_NUMBER="${{ steps.issue-info.outputs.number }}"
80+
ISSUE_TITLE="${{ steps.issue-info.outputs.title }}"
81+
ISSUE_URL="${{ steps.issue-info.outputs.html_url }}"
82+
AUTHOR_LOGIN="${{ steps.issue-info.outputs.author_login }}"
83+
AUTHOR_URL="${{ steps.issue-info.outputs.author_html_url }}"
84+
ISSUE_STATE="${{ steps.issue-info.outputs.state }}"
85+
ISSUE_LABELS="${{ steps.issue-info.outputs.labels }}"
86+
CREATED_AT="${{ steps.issue-info.outputs.created_at }}"
87+
else
88+
ISSUE_NUMBER="${{ github.event.issue.number }}"
89+
ISSUE_TITLE="${{ github.event.issue.title }}"
90+
ISSUE_URL="${{ github.event.issue.html_url }}"
91+
AUTHOR_LOGIN="${{ github.event.issue.user.login }}"
92+
AUTHOR_URL="${{ github.event.issue.user.html_url }}"
93+
ISSUE_STATE="${{ github.event.issue.state }}"
94+
ISSUE_LABELS="${{ github.event.issue.labels[0].name && join(github.event.issue.labels.*.name, ', ') || 'None' }}"
95+
CREATED_AT="${{ github.event.issue.created_at }}"
96+
fi
97+
7798
# Create a temporary JSON file
78-
cat > discord_payload.json << 'EOF'
99+
cat > discord_payload.json << EOF
79100
{
80101
"avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
81102
"embeds": [
82103
{
83-
"title": "${{ steps.action-info.outputs.emoji }} Issue ${{ steps.action-info.outputs.action_text }}: #${{ github.event.issue.number }}",
84-
"description": "${{ github.event.issue.title }}",
85-
"url": "${{ github.event.issue.html_url }}",
104+
"title": "${{ steps.action-info.outputs.emoji }} Issue ${{ steps.action-info.outputs.action_text }}: #${ISSUE_NUMBER}",
105+
"description": "${ISSUE_TITLE}",
106+
"url": "${ISSUE_URL}",
86107
"color": ${{ steps.action-info.outputs.color }},
87108
"thumbnail": {
88109
"url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
89110
},
90111
"fields": [
91112
{
92113
"name": "📋 Issue #",
93-
"value": "`#${{ github.event.issue.number }}`",
114+
"value": "\`#${ISSUE_NUMBER}\`",
94115
"inline": true
95116
},
96117
{
97118
"name": "👤 Author",
98-
"value": "[${{ github.event.issue.user.login }}](${{ github.event.issue.user.html_url }})",
119+
"value": "[${AUTHOR_LOGIN}](${AUTHOR_URL})",
99120
"inline": true
100121
},
101122
{
@@ -105,21 +126,21 @@ jobs:
105126
},
106127
{
107128
"name": "🏷️ Labels",
108-
"value": "${{ github.event.issue.labels[0].name && join(github.event.issue.labels.*.name, ', ') || 'None' }}",
129+
"value": "${ISSUE_LABELS}",
109130
"inline": true
110131
},
111132
{
112133
"name": "📊 State",
113-
"value": "`${{ github.event.issue.state }}`",
134+
"value": "\`${ISSUE_STATE}\`",
114135
"inline": true
115136
},
116137
{
117138
"name": "🔗 View Issue",
118-
"value": "[Issue Page](${{ github.event.issue.html_url }})",
139+
"value": "[Issue Page](${ISSUE_URL})",
119140
"inline": true
120141
}
121142
],
122-
"timestamp": "${{ github.event.issue.created_at }}",
143+
"timestamp": "${CREATED_AT}",
123144
"footer": {
124145
"text": "Workout Cool • Issue ${{ steps.action-info.outputs.action_text }}",
125146
"icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"

0 commit comments

Comments
 (0)