From a89f454ec0c2f6fd09ffe006c4d9aeafe331e85e Mon Sep 17 00:00:00 2001 From: Jacob Mathison Date: Tue, 23 Jun 2026 10:32:39 -0500 Subject: [PATCH] fix(ci): deploy hosted app over ssh --- .env | 2 +- .woodpecker.yml | 29 ++++++----- package-lock.json | 4 +- package.json | 2 +- scripts/woodpecker/notify-discord.sh | 74 +++++++++++++++++----------- src/data/changelog.json | 3 +- 6 files changed, 68 insertions(+), 46 deletions(-) diff --git a/.env b/.env index e068092..44c2169 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ VITE_LAST_BUILD_DATE=20260623 -VITE_LAST_SUCCESSFUL_COMMIT=f531e1b +VITE_LAST_SUCCESSFUL_COMMIT=ab0383a diff --git a/.woodpecker.yml b/.woodpecker.yml index 67f1e0a..6b588cd 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -5,13 +5,12 @@ when: steps: notify-start: - image: python:3.12-alpine + image: node:24-bookworm environment: DEPLOY_TARGET_URL: http://bone-kingdom.tabitha.tealthrone/ DISCORD_DEPLOY_WEBHOOK_URL: from_secret: discord_deploy_webhook_url commands: - - apk add --no-cache curl - sh scripts/woodpecker/notify-discord.sh started "Bone Kingdom Deploy Started" 5793266 validate: @@ -23,29 +22,36 @@ steps: - npm run web:build deploy: - image: alpine:3.20 + image: node:24-bookworm environment: DEPLOY_TARGET_URL: http://bone-kingdom.tabitha.tealthrone/ - volumes: - - /Users/Tabitha/.openclaw/workspace_father/blb-throne-of-the-bone-king/dist/renderer:/deploy-target + DEPLOY_HOST: 100.108.87.106 + DEPLOY_USER: Tabitha + DEPLOY_PATH: /Users/Tabitha/.openclaw/workspace_father/blb-throne-of-the-bone-king/dist/renderer + DEPLOY_SSH_PRIVATE_KEY: + from_secret: deploy_ssh_private_key commands: - - apk add --no-cache curl rsync + - apt-get update + - apt-get install -y --no-install-recommends openssh-client rsync - test -d dist/renderer - - mkdir -p /deploy-target - - rsync -a --delete dist/renderer/ /deploy-target/ + - mkdir -p ~/.ssh + - printf '%s\n' "$DEPLOY_SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 + - chmod 600 ~/.ssh/id_ed25519 + - ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts + - ssh "$DEPLOY_USER@$DEPLOY_HOST" "mkdir -p '$DEPLOY_PATH'" + - rsync -az --delete dist/renderer/ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/" - curl -fsS "$DEPLOY_TARGET_URL" >/tmp/bone-kingdom-index.html - grep -q '
' /tmp/bone-kingdom-index.html depends_on: - validate notify-success: - image: python:3.12-alpine + image: node:24-bookworm environment: DEPLOY_TARGET_URL: http://bone-kingdom.tabitha.tealthrone/ DISCORD_DEPLOY_WEBHOOK_URL: from_secret: discord_deploy_webhook_url commands: - - apk add --no-cache curl - sh scripts/woodpecker/notify-discord.sh succeeded "Bone Kingdom Deploy Succeeded" 5763719 depends_on: - deploy @@ -53,13 +59,12 @@ steps: status: [success] notify-failure: - image: python:3.12-alpine + image: node:24-bookworm environment: DEPLOY_TARGET_URL: http://bone-kingdom.tabitha.tealthrone/ DISCORD_DEPLOY_WEBHOOK_URL: from_secret: discord_deploy_webhook_url commands: - - apk add --no-cache curl - sh scripts/woodpecker/notify-discord.sh failed "Bone Kingdom Deploy Failed" 15158332 when: status: [failure] diff --git a/package-lock.json b/package-lock.json index 68336e5..f478175 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "BlbThroneOfTheBoneKing", - "version": "0.0.3", + "version": "0.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "BlbThroneOfTheBoneKing", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@react-native-async-storage/async-storage": "^3.1.1", "@react-native/new-app-screen": "0.85.3", diff --git a/package.json b/package.json index b6c3a60..2aa1e86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "BlbThroneOfTheBoneKing", - "version": "0.0.3", + "version": "0.0.4", "private": true, "main": "dist/electron/main.js", "scripts": { diff --git a/scripts/woodpecker/notify-discord.sh b/scripts/woodpecker/notify-discord.sh index 72915ed..85571b9 100755 --- a/scripts/woodpecker/notify-discord.sh +++ b/scripts/woodpecker/notify-discord.sh @@ -11,38 +11,54 @@ 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 +webhook_url="${DISCORD_DEPLOY_WEBHOOK_URL:-}" + +if [ -z "$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 +node - "$status" "$title" "$color" "$target_url" "$repo" "$branch" "$short_commit" "$build_url" "$webhook_url" <<'NODE' +const [ + status, + title, + color, + targetUrl, + repo, + branch, + shortCommit, + buildUrl, + webhookUrl, +] = process.argv.slice(2); -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}, - ], - } - ], +const payload = { + content: `Bone Kingdom deploy status: ${status}`, + embeds: [ + { + title, + url: targetUrl, + color: Number(color), + fields: [ + { name: 'Status', value: status, inline: true }, + { name: 'Repo', value: repo, inline: true }, + { name: 'Branch', value: branch, inline: true }, + { name: 'Commit', value: shortCommit, inline: true }, + { name: 'Target', value: targetUrl, inline: false }, + { name: 'Build', value: buildUrl, inline: false }, + ], + }, + ], +}; + +const response = await fetch(webhookUrl, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(payload), +}); + +if (!response.ok) { + const responseBody = await response.text(); + console.error(`Discord notification failed: ${response.status} ${responseBody}`); + process.exit(1); } -print(json.dumps(payload)) -PY - -curl -fsS \ - -H "Content-Type: application/json" \ - --data-binary @/tmp/discord-payload.json \ - "$DISCORD_DEPLOY_WEBHOOK_URL" +NODE diff --git a/src/data/changelog.json b/src/data/changelog.json index db14690..be66631 100644 --- a/src/data/changelog.json +++ b/src/data/changelog.json @@ -8,7 +8,8 @@ "changes": [ "Added deploy lifecycle Discord notifications for start, success, and failure states.", "Added Woodpecker validation for lint, tests, and the Vite web build.", - "Added a deployment step that syncs the built renderer bundle to the local nginx host." + "Added a deployment step that syncs the built renderer bundle to the local nginx host.", + "Updated deployment to publish over a dedicated SSH deploy key instead of a Kubernetes host volume." ] }, {