2026-11-19 02:12:53 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# Deploy a committed git ref to the server. Run from the repo root (Git Bash on Windows, or Linux/CI):
|
|
|
|
|
# bash server/deploy/deploy.sh deploy HEAD
|
|
|
|
|
# bash server/deploy/deploy.sh --reset-db ... and reset the DB (test system: seed accounts michi/benni)
|
|
|
|
|
# bash server/deploy/deploy.sh --ref <sha|tag> --host root@<server>
|
|
|
|
|
# Only committed code is deployed (git archive), never the working tree. The server side (remote-release.sh)
|
|
|
|
|
# installs the release, backs up the DB, switches the `current` link, checks /healthz and rolls back on failure.
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
HOST="root@roboclash.michael-media.de"
|
|
|
|
|
REF="HEAD"
|
|
|
|
|
RESET=0
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
--host) HOST="$2"; shift 2 ;;
|
|
|
|
|
--ref) REF="$2"; shift 2 ;;
|
|
|
|
|
--reset-db) RESET=1; shift ;;
|
|
|
|
|
*) echo "unknown option: $1"; exit 2 ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
cd "$(git rev-parse --show-toplevel)"
|
2026-11-19 15:14:56 +01:00
|
|
|
git diff --quiet HEAD -- game server admin tools || echo "!! uncommitted changes in game/server/admin are NOT deployed (only $REF)"
|
2026-11-19 02:12:53 +01:00
|
|
|
SHA=$(git rev-parse --short "$REF")
|
|
|
|
|
REL="$(date -u +%Y%m%d-%H%M%S)-$SHA"
|
|
|
|
|
TAR="$(mktemp -t rc-XXXXXX).tgz"
|
|
|
|
|
trap 'rm -f "$TAR"' EXIT
|
|
|
|
|
|
|
|
|
|
echo ">> release $REL -> $HOST"
|
2026-11-19 15:14:56 +01:00
|
|
|
git archive --format=tar.gz -o "$TAR" "$REF" game server admin tools
|
2026-11-19 02:12:53 +01:00
|
|
|
scp -q "$TAR" "$HOST:/tmp/rc-$REL.tgz"
|
|
|
|
|
tr -d '\r' < server/deploy/remote-release.sh | ssh "$HOST" bash -s -- "$REL" "$SHA" "$RESET"
|