Files
blb-throne-of-the-bone-king/scripts/woodpecker/notify-discord.sh
T
jacob-mathison ab0383aaf3
ci/woodpecker/push/woodpecker Pipeline failed
Lint and Build Checks / Lint, Test, and Build (push) Failing after 393h18m24s
feat(ci): add woodpecker deploy pipeline
2026-06-23 10:19:05 -05:00

49 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
set -eu
status="${1:-unknown}"
title="${2:-Bone Kingdom deploy update}"
color="${3:-5793266}"
target_url="${DEPLOY_TARGET_URL:-http://bone-kingdom.tabitha.tealthrone/}"
commit="${CI_COMMIT_SHA:-unknown}"
short_commit="$(printf '%s' "$commit" | cut -c 1-12)"
branch="${CI_COMMIT_BRANCH:-unknown}"
repo="${CI_REPO:-jacob-mathison/blb-throne-of-the-bone-king}"
build_url="${CI_PIPELINE_URL:-${CI_BUILD_LINK:-http://localhost:13580/}}"
if [ -z "${DISCORD_DEPLOY_WEBHOOK_URL:-}" ]; then
echo "DISCORD_DEPLOY_WEBHOOK_URL is not configured; skipping Discord notification."
exit 0
fi
python3 - "$status" "$title" "$color" "$target_url" "$repo" "$branch" "$short_commit" "$build_url" <<'PY' > /tmp/discord-payload.json
import json
import sys
status, title, color, target_url, repo, branch, short_commit, build_url = sys.argv[1:9]
payload = {
"content": f"Bone Kingdom deploy status: {status}",
"embeds": [
{
"title": title,
"url": target_url,
"color": int(color),
"fields": [
{"name": "Status", "value": status, "inline": True},
{"name": "Repo", "value": repo, "inline": True},
{"name": "Branch", "value": branch, "inline": True},
{"name": "Commit", "value": short_commit, "inline": True},
{"name": "Target", "value": target_url, "inline": False},
{"name": "Build", "value": build_url, "inline": False},
],
}
],
}
print(json.dumps(payload))
PY
curl -fsS \
-H "Content-Type: application/json" \
--data-binary @/tmp/discord-payload.json \
"$DISCORD_DEPLOY_WEBHOOK_URL"