From 0faf4e5f389f60b086a2deb2b8fe622750984ad1 Mon Sep 17 00:00:00 2001 From: Mack Date: Tue, 11 Aug 2026 03:54:32 +1200 Subject: [PATCH] Switch deploy tooling to Gitea (no GitHub) Co-Authored-By: Claude Opus 4.8 --- .gitignore | 3 +-- README.md | 35 ++++++++++++++++++++++++------- deploy.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 9 deletions(-) create mode 100755 deploy.sh diff --git a/.gitignore b/.gitignore index 9b319a5..82520ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -Dockerfile.inline -deploy-nogit.sh +/tmp/ diff --git a/README.md b/README.md index e4c85d1..8b9e41f 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,32 @@ Static single-file WattHound demo (ABC Electrical) served at https://watthound-demo.sculpt7.com -Deployed via Coolify (project `watthound-demo`) using the Dockerfile build pack: -nginx:alpine serving `index.html`. +## Hosting (NO GitHub) -## Update the live demo -1. Replace `index.html` with the new build. -2. `git commit -am "update demo" && git push` -3. Redeploy: Coolify auto-deploy on push (if webhook enabled), or trigger the - Coolify deploy for app `watthound-demo`. +- **Git host:** `gitea.sculpt.co.nz/macjones/watthound-demo` (Mac's own self-hosted + Gitea, public repo). GitHub is not involved anywhere. +- **Runtime:** Coolify app `watthound-demo-gitea` + (uuid `hd9qde2w6xrmnippah409jgt`) builds the `Dockerfile` + (nginx:alpine serving `index.html`) straight from Gitea `main`. + +## Update the live demo (repeatable, no GitHub) + +``` +./deploy.sh # commit ./index.html, push to Gitea, redeploy, verify +./deploy.sh /path/to/new/index.html # drop in a new build first, then the above +``` + +That script: commits `index.html`, `git push gitea main`, triggers the Coolify +deploy via API, then polls the FQDN until it serves the new byte size. + +### Manual equivalent + +``` +git add index.html && git commit -m "update demo" +git push gitea main +# then trigger Coolify (token from myPKA .env, never printed): +BASE="$(grep '^COOLIFY_URL=' /Users/macjones/Projects/watthound/mypka/.env | cut -d= -f2-)/api/v1" +TOKEN="$(grep '^COOLIFY_API_TOKEN=' /Users/macjones/Projects/watthound/mypka/.env | cut -d= -f2-)" +curl -sS -X POST -H "Authorization: Bearer $TOKEN" \ + "$BASE/deploy?uuid=hd9qde2w6xrmnippah409jgt&force=true" +``` diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..769fe04 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# Deploy the WattHound demo. NO GitHub involved. +# +# Source of truth : ./index.html (committed to Gitea, built by Coolify) +# Git host : gitea.sculpt.co.nz/macjones/watthound-demo (public, Mac's own server) +# Runtime : Coolify app "watthound-demo-gitea" -> nginx:alpine, FQDN +# https://watthound-demo.sculpt7.com +# +# Flow: commit index.html -> push to Gitea -> trigger Coolify deploy -> verify. +# +# Usage: ./deploy.sh # commits & pushes ./index.html, then deploys +# ./deploy.sh /path/to/new/index.html # copies that file in first +# +# Requires: COOLIFY_API_TOKEN + COOLIFY_URL in the myPKA .env (never printed). +# git push access to the gitea remote (already configured / keychain). +set -euo pipefail + +SITE_DIR="$(cd "$(dirname "$0")" && pwd)" +ENV_FILE="/Users/macjones/Projects/watthound/mypka/.env" +APP_UUID="${APP_UUID:-hd9qde2w6xrmnippah409jgt}" # Coolify app watthound-demo-gitea +FQDN="https://watthound-demo.sculpt7.com" + +# Optional: pull in a new build from an arbitrary path +if [ "${1:-}" != "" ]; then + cp "$1" "$SITE_DIR/index.html" + echo "Copied $1 -> index.html ($(wc -c < "$SITE_DIR/index.html") bytes)" +fi + +TOKEN="$(grep '^COOLIFY_API_TOKEN=' "$ENV_FILE" | head -1 | cut -d= -f2-)" +URL="$(grep '^COOLIFY_URL=' "$ENV_FILE" | head -1 | cut -d= -f2-)" +case "$URL" in */api/v1) BASE="$URL";; *) BASE="${URL%/}/api/v1";; esac + +cd "$SITE_DIR" +if ! git diff --quiet -- index.html || ! git diff --cached --quiet -- index.html; then + git add index.html + git commit -m "Update demo ($(wc -c < index.html) bytes) $(date +%Y-%m-%d)" >/dev/null + echo "Committed index.html" +else + echo "index.html unchanged since last commit (will still redeploy current HEAD)" +fi + +echo "Pushing to Gitea..." +git push gitea main + +echo "Triggering Coolify deploy (app $APP_UUID)..." +curl -sS -X POST -H "Authorization: Bearer $TOKEN" "$BASE/deploy?uuid=$APP_UUID&force=true" \ + | python3 -c 'import sys,json;d=json.load(sys.stdin);print(json.dumps(d))' + +echo "Verifying $FQDN (may take ~30-60s to rebuild)..." +for i in $(seq 1 20); do + read -r CODE SIZE < <(curl -sS --max-time 15 -o /tmp/wh_deploy_check.html \ + -w "%{http_code} %{size_download}" -L "$FQDN/" 2>/dev/null || echo "000 0") + WANT="$(wc -c < index.html | tr -d ' ')" + echo " check $i: http=$CODE size=$SIZE (want $WANT)" + if [ "$CODE" = "200" ] && [ "$SIZE" = "$WANT" ]; then + echo "LIVE and verified."; exit 0 + fi + sleep 10 +done +echo "WARNING: not verified within timeout; check Coolify deployment logs." +exit 1