mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 21:02:41 +00:00
Harden Discord webhook payload and logging
Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com>
This commit is contained in:
parent
f7e9f726f8
commit
1f37236f80
55
.github/workflows/release.yaml
vendored
55
.github/workflows/release.yaml
vendored
@ -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" \
|
||||||
"embeds": [
|
--arg repo "$REPO" \
|
||||||
{
|
--arg linux "$LINUX_URL" \
|
||||||
"title": "Release ${TAG_NAME}",
|
--arg windows "$WINDOWS_URL" \
|
||||||
"url": "https://github.com/${REPO}/releases/tag/${TAG_NAME}",
|
--arg sha "$SHA_URL" \
|
||||||
"color": 5793266,
|
--arg footer "Clumsy's World EQEmu Release" \
|
||||||
"thumbnail": { "url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" },
|
'{
|
||||||
"fields": [
|
embeds: [
|
||||||
{ "name": "Linux (x64)", "value": "[Download](${LINUX_URL})", "inline": true },
|
{
|
||||||
{ "name": "Windows (x64)", "value": "[Download](${WINDOWS_URL})", "inline": true },
|
title: ("Release " + $tag),
|
||||||
{ "name": "Checksums", "value": "[SHA256SUMS.txt](${SHA_URL})", "inline": false }
|
url: ("https://github.com/" + $repo + "/releases/tag/" + $tag),
|
||||||
],
|
color: 5793266,
|
||||||
"footer": { "text": "Clumsy's World EQEmu Release" }
|
thumbnail: { url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" },
|
||||||
}
|
fields: [
|
||||||
]
|
{ name: "Linux (x64)", value: ("[Download](" + $linux + ")"), inline: true },
|
||||||
}
|
{ name: "Windows (x64)", value: ("[Download](" + $windows + ")"), inline: true },
|
||||||
EOF
|
{ name: "Checksums", value: ("[SHA256SUMS.txt](" + $sha + ")"), inline: false }
|
||||||
)
|
],
|
||||||
curl -sS -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" || \
|
footer: { text: $footer }
|
||||||
echo "Failed to send Discord notification."
|
}
|
||||||
|
]
|
||||||
|
}')
|
||||||
|
response_file=$(mktemp)
|
||||||
|
http_code=$(curl -sS -o "$response_file" -w "%{http_code}" \
|
||||||
|
-H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL")
|
||||||
|
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user