#!/usr/bin/env bash # Deploys the pushed master to village.blax.at (edgerealm) and checks it is live. # Touches only the game-village-politics-frontend checkout and container on that shared host. # On Windows, put the Windows OpenSSH client first: PATH="/c/Windows/System32/OpenSSH:$PATH". set -euo pipefail HOST=root@static.64.40.140.128.clients.your-server.de DIR=/mnt/HC_Volume_102040804/srv/game-village-politics-frontend REPO=ssh://git@git.blax.at:222/blax-software/game-village-politics-frontend.git URL=https://village.blax.at cd "$(dirname "$0")/.." if [ -n "$(git status --porcelain)" ]; then echo "Uncommitted changes: commit and push first." >&2 exit 1 fi git fetch -q origin LOCAL=$(git rev-parse HEAD) REMOTE=$(git rev-parse origin/master) if [ "$LOCAL" != "$REMOTE" ]; then echo "HEAD ${LOCAL:0:7} is not origin/master ${REMOTE:0:7}: push (or pull) first." >&2 exit 1 fi echo "==> Deploying ${LOCAL:0:7} to edgerealm" ssh -o BatchMode=yes "$HOST" "[ -d $DIR ] || git clone -q $REPO $DIR" ssh -o BatchMode=yes "$HOST" "cd $DIR && ./deploy.sh" | { grep -E '==> Deployment complete|ERROR|Container village-politics-frontend Started' || true; } DEPLOYED=$(ssh -o BatchMode=yes "$HOST" "cd $DIR && git rev-parse HEAD") if [ "$DEPLOYED" != "$LOCAL" ]; then echo "Server is on ${DEPLOYED:0:7}, expected ${LOCAL:0:7}." >&2 exit 1 fi # The container needs a moment to start serving. /village/1 checks the SPA fallback. for _ in $(seq 1 20); do PAGE=$(curl -s -o /dev/null -w '%{http_code}' "$URL/" || true) ROUTE=$(curl -s -o /dev/null -w '%{http_code}' "$URL/village/1" || true) if [ "$PAGE" = 200 ] && [ "$ROUTE" = 200 ]; then echo "Live: $URL at ${LOCAL:0:7}" exit 0 fi sleep 2 done echo "Deployed ${LOCAL:0:7}, but $URL answers page=$PAGE route=$ROUTE." >&2 exit 1