Harden Discord webhook payload and logging

Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-25 01:56:49 +00:00
parent f7e9f726f8
commit 1f37236f80

View File

@ -315,24 +315,37 @@ jobs:
LINUX_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/eqemu-server-linux-x64.zip" LINUX_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/eqemu-server-linux-x64.zip"
WINDOWS_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/eqemu-server-windows-x64.zip" WINDOWS_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/eqemu-server-windows-x64.zip"
SHA_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/SHA256SUMS.txt" SHA_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/SHA256SUMS.txt"
payload=$(cat <<EOF payload=$(jq -n \
--arg tag "$TAG_NAME" \
--arg repo "$REPO" \
--arg linux "$LINUX_URL" \
--arg windows "$WINDOWS_URL" \
--arg sha "$SHA_URL" \
--arg footer "Clumsy's World EQEmu Release" \
'{
embeds: [
{ {
"embeds": [ title: ("Release " + $tag),
{ url: ("https://github.com/" + $repo + "/releases/tag/" + $tag),
"title": "Release ${TAG_NAME}", color: 5793266,
"url": "https://github.com/${REPO}/releases/tag/${TAG_NAME}", thumbnail: { url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" },
"color": 5793266, fields: [
"thumbnail": { "url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" }, { name: "Linux (x64)", value: ("[Download](" + $linux + ")"), inline: true },
"fields": [ { name: "Windows (x64)", value: ("[Download](" + $windows + ")"), inline: true },
{ "name": "Linux (x64)", "value": "[Download](${LINUX_URL})", "inline": true }, { name: "Checksums", value: ("[SHA256SUMS.txt](" + $sha + ")"), inline: false }
{ "name": "Windows (x64)", "value": "[Download](${WINDOWS_URL})", "inline": true },
{ "name": "Checksums", "value": "[SHA256SUMS.txt](${SHA_URL})", "inline": false }
], ],
"footer": { "text": "Clumsy's World EQEmu Release" } footer: { text: $footer }
} }
] ]
} }')
EOF response_file=$(mktemp)
) http_code=$(curl -sS -o "$response_file" -w "%{http_code}" \
curl -sS -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" || \ -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL")
echo "Failed to send Discord notification." curl_status=$?
if [ $curl_status -ne 0 ]; then
echo "Failed to send Discord notification (curl exit $curl_status)."
exit 0
fi
if [ "$http_code" -lt 200 ] || [ "$http_code" -ge 300 ]; then
echo "Discord notification failed with HTTP $http_code: $(cat "$response_file")"
fi