#!/usr/bin/env bash # Pull web-edit commits from VPS, then push everything back. # Retries the container push (up to 3x) if a VPS web-edit landed between # our pull and push — receive.denyNonFastForwards is enabled on the bare repo # so those races are rejected rather than silently dropped. # Usage: bash scripts/sync-vps.sh set -e cd "$(dirname "$0")/.." echo "==> Pulling web-edit commits from VPS..." git pull --rebase --autostash vps main echo "==> Pushing site submodule to VPS..." (cd site && git push vps main) echo "==> Pushing container repo to VPS..." for attempt in 1 2 3; do if git push vps main; then break elif [ $attempt -lt 3 ]; then echo " Push rejected — VPS has new commits, pulling and retrying (attempt $attempt)..." git pull --rebase --autostash vps main else echo " Push failed after 3 attempts — run sync-vps.sh again manually." exit 1 fi done echo "==> Done."