spb/svgarden Public
SVGarden — searchable bank of 74 self-contained SVG+CSS animation snippets (svgarden.dev)
HTML 79.2%
Astro 10.3%
JavaScript 6%
CSS 3.7%
Shell 0.8%
1#!/usr/bin/env bash2# ============================================================3# SVGarden — https://www.svgarden.dev4# Author : Simon-Pierre Boucher5# Contact: contact@spboucher.ai6# File : scripts/deploy.sh7# Desc : Deploy to node M3U96b — sync/pull, npm ci, build, pm2, health checks8# ============================================================9set -euo pipefail1011NODE="${SVGARDEN_NODE:-M3U96b}"12APP_DIR="~/apps/svgarden"13LOCAL_URL="http://127.0.0.1:4321"14PUBLIC_URL="https://www.svgarden.dev"15SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"16REPO_DIR="$(dirname "$SCRIPT_DIR")"1718step() { printf '\n\033[1;35m▸ %s\033[0m\n' "$*"; }1920# 1. Get the latest code onto the node.21# With a git remote configured on the node we `git pull` (per CLAUDE.md §9);22# until one exists we rsync from this working copy instead.23if ssh "$NODE" "cd $APP_DIR 2>/dev/null && git remote get-url origin >/dev/null 2>&1"; then24 step "git pull on $NODE"25 ssh "$NODE" "cd $APP_DIR && git pull --ff-only"26else27 step "rsync source → $NODE:$APP_DIR (no git remote yet)"28 ssh "$NODE" "mkdir -p $APP_DIR"29 rsync -az --delete \30 --exclude node_modules --exclude dist --exclude .git \31 --exclude '.env*' --exclude ngrok.yml \32 "$REPO_DIR/" "$NODE:$APP_DIR/"33fi3435# 2. Install exact deps + build (validation runs inside `npm run build`).36step "npm ci + npm run build on $NODE"37ssh "$NODE" "export PATH=/opt/homebrew/bin:\$PATH; cd $APP_DIR && npm ci --no-audit --no-fund && npm run build"3839# 3. (Re)start server + tunnel under pm2.40step "pm2 startOrRestart"41ssh "$NODE" "export PATH=/opt/homebrew/bin:\$PATH; cd $APP_DIR && pm2 startOrRestart ecosystem.config.cjs && pm2 save"4243# 4. Health checks.44step "health check $LOCAL_URL (on $NODE)"45sleep 346ssh "$NODE" "curl -fsS -o /dev/null -w 'local %{http_code} %{time_total}s\n' $LOCAL_URL/healthz && curl -fsS $LOCAL_URL/healthz && echo"4748step "health check $PUBLIC_URL"49if curl -fsS -o /dev/null -m 20 -w 'public %{http_code} %{time_total}s\n' "$PUBLIC_URL/healthz"; then50 curl -fsS -m 20 "$PUBLIC_URL/healthz" && echo51else52 cat <<'EOF'53⚠ Public URL unreachable. The local server is up; the tunnel is not.54 Check on the node:55 pm2 logs svgarden-tunnel --lines 3056 Likely causes:57 • www.svgarden.dev not reserved as a custom domain in the ngrok dashboard58 • DNS CNAME for www.svgarden.dev not pointed at ngrok yet59 • ngrok agent not authenticated (`ngrok config add-authtoken <token>`)60EOF61 exit 162fi6364step "status summary"65ssh "$NODE" "export PATH=/opt/homebrew/bin:\$PATH; pm2 ls | grep -E 'svgarden|name' || true"66echo "✔ SVGarden deployed — $PUBLIC_URL"67