Keep server details out of the repo; deploy target comes from HOST or .deploy.env

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-02 01:19:28 -08:00
parent dc2b12a3c6
commit 21202c2ca3
6 changed files with 17 additions and 13 deletions

View file

@ -1,12 +1,13 @@
#!/usr/bin/env bash
# Deploy this checkout (including uncommitted changes) over SSH:
# HOST=root@<server> ./deploy.sh
# HOST=root@<server> ./deploy.sh # elsewhere
# or put HOST=root@<server> in .deploy.env (gitignored; keep server details out of the repo).
# Copies app/ and compose.yml to /opt/tools, rebuilds and restarts the container,
# then waits for it to report healthy. Paste data in /opt/tools/data is kept.
set -euo pipefail
HOST=${HOST:?set HOST=root@<server>}
cd "$(dirname "$0")"
[ -z "${HOST:-}" ] && [ -f .deploy.env ] && . ./.deploy.env
[ -n "${HOST:-}" ] || { echo "usage: HOST=root@<server> $0 (or set HOST in .deploy.env)" >&2; exit 1; }
node --test tests/ >/dev/null || { echo "tests failed; not deploying" >&2; exit 1; }
tar -czf - --exclude=__pycache__ --exclude=data app compose.yml |
ssh "$HOST" 'set -e; mkdir -p /opt/tools && rm -rf /opt/tools/app && tar --no-same-owner -xzf - -C /opt/tools'