Switch deploy tooling to Gitea (no GitHub)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 03:54:32 +12:00
parent 3d1eacc2a3
commit 0faf4e5f38
3 changed files with 90 additions and 9 deletions

3
.gitignore vendored
View File

@@ -1,2 +1 @@
Dockerfile.inline
deploy-nogit.sh
/tmp/

View File

@@ -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"
```

61
deploy.sh Executable file
View File

@@ -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