fix(ci): deploy hosted app over ssh
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
VITE_LAST_BUILD_DATE=20260623
|
||||
VITE_LAST_SUCCESSFUL_COMMIT=f531e1b
|
||||
VITE_LAST_SUCCESSFUL_COMMIT=ab0383a
|
||||
|
||||
+17
-12
@@ -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 '<div id="root">' /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]
|
||||
|
||||
Generated
+2
-2
@@ -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",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "BlbThroneOfTheBoneKing",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"private": true,
|
||||
"main": "dist/electron/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user