@@ -66,45 +66,49 @@ jobs:
6666 run : |
6767 TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
6868
69- # Template for the embed
70- EMBED_TEMPLATE=$(cat <<EOF
71- {
72- "title": "📝 New Commit Pushed (Notify #${{ github.run_number }})",
73- "description": "%s",
74- "url": "$COMMIT_URL",
75- "color": 3447003,
76- "fields": [
77- {"name": "🔔 Notify", "value": "#${{ github.run_number }} (attempt ${{ github.run_attempt }})", "inline": true},
78- {"name": "🔗 Commit", "value": "[$COMMIT_SHA_SHORT]($COMMIT_URL)", "inline": true},
79- {"name": "👤 Author", "value": "$COMMIT_AUTHOR", "inline": true},
80- {"name": "🌿 Branch", "value": "\`$BRANCH_NAME\`", "inline": true},
81- {"name": "📊 Stats", "value": "**Files:** $FILES_CHANGED | **+$INSERTIONS** | **-$DELETIONS**", "inline": false},
82- {"name": "📄 Changed Files", "value": "%s", "inline": false}
83- ],
84- "timestamp": "$TIMESTAMP"
85- }
86- EOF
87- )
69+ # Build the embed object directly with jq
70+ EMBED_JSON=$(jq -n \
71+ --arg desc "$COMMIT_MESSAGE" \
72+ --arg url "$COMMIT_URL" \
73+ --arg c_sha "$COMMIT_SHA_SHORT" \
74+ --arg c_author "$COMMIT_AUTHOR" \
75+ --arg branch "$BRANCH_NAME" \
76+ --arg files_changed "$FILES_CHANGED" \
77+ --arg insertions "$INSERTIONS" \
78+ --arg deletions "$DELETIONS" \
79+ --arg changed_files "$CHANGED_FILES" \
80+ --arg timestamp "$TIMESTAMP" \
81+ '{
82+ "title": "📝 New Commit Pushed (Notify #${{ github.run_number }})",
83+ "description": $desc,
84+ "url": $url,
85+ "color": 3447003,
86+ "fields": [
87+ {"name": "🔔 Notify", "value": "#${{ github.run_number }} (attempt ${{ github.run_attempt }})", "inline": true},
88+ {"name": "🔗 Commit", "value": "[\($c_sha)](\($url))", "inline": true},
89+ {"name": "👤 Author", "value": $c_author, "inline": true},
90+ {"name": "🌿 Branch", "value": "`\($branch)`", "inline": true},
91+ {"name": "📊 Stats", "value": "**Files:** \($files_changed) | **+\($insertions)** | **-\($deletions)**", "inline": false},
92+ {"name": "📄 Changed Files", "value": $changed_files, "inline": false}
93+ ],
94+ "timestamp": $timestamp
95+ }')
8896
89- # Use jq to safely build the final JSON payload
97+ # Build the final payload, adding mention if necessary
9098 if [ -n "$MENTION_USER_ID" ]; then
9199 JSON_PAYLOAD=$(jq -n \
92100 --arg content "<@$MENTION_USER_ID>" \
93101 --argjson allowed_mentions "{\"users\":[\"$MENTION_USER_ID\"]}" \
94102 --arg username "GitHub Bot" \
95103 --arg avatar_url "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" \
96- --arg commit_msg "$COMMIT_MESSAGE" \
97- --arg changed_files "$CHANGED_FILES" \
98- --argjson embed_template "$(printf "$EMBED_TEMPLATE" "" "")" \
99- '$embed_template.description = $commit_msg | $embed_template.fields[5].value = $changed_files | {username: $username, avatar_url: $avatar_url, content: $content, allowed_mentions: $allowed_mentions, embeds: [$embed_template]}')
104+ --argjson embed "$EMBED_JSON" \
105+ '{username: $username, avatar_url: $avatar_url, content: $content, allowed_mentions: $allowed_mentions, embeds: [$embed]}')
100106 else
101107 JSON_PAYLOAD=$(jq -n \
102108 --arg username "GitHub Bot" \
103109 --arg avatar_url "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" \
104- --arg commit_msg "$COMMIT_MESSAGE" \
105- --arg changed_files "$CHANGED_FILES" \
106- --argjson embed_template "$(printf "$EMBED_TEMPLATE" "" "")" \
107- '$embed_template.description = $commit_msg | $embed_template.fields[5].value = $changed_files | {username: $username, avatar_url: $avatar_url, embeds: [$embed_template]}')
110+ --argjson embed "$EMBED_JSON" \
111+ '{username: $username, avatar_url: $avatar_url, embeds: [$embed]}')
108112 fi
109113
110114 # send and capture response
0 commit comments