#!/usr/bin/env bash
# Publish the blog to Tower (nginx :8090 -> https://bus.saillant.cc)
set -euo pipefail
cd "$(dirname "$0")"

TOWER="clems@192.168.0.120"
DEST="/home/clems/bus-blog/public/"

echo "==> hugo build"
hugo --minify --cleanDestinationDir

echo "==> rsync to $TOWER:$DEST"
rsync -az --delete public/ "$TOWER:$DEST"

echo "==> smoke test"
curl -sfI https://bus.saillant.cc/ >/dev/null \
  && echo "OK: https://bus.saillant.cc" \
  || { echo "WARN: public URL not reachable (DNS/route?)"; exit 1; }
