#!/usr/bin/env bash # Sync production checkout to the deploy branch tip (used by deploy webhook + CI over SSH). set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo_root" branch="${DEPLOY_BRANCH:-main}" remote="${DEPLOY_GIT_REMOTE:-origin}" if [[ ! -d .git ]]; then echo "[git-sync-deploy] ERROR: ${repo_root} is not a git repository" >&2 exit 1 fi echo "[git-sync-deploy] fetching ${remote}/${branch}..." git fetch "$remote" "$branch" git checkout "$branch" git reset --hard "${remote}/${branch}" echo "[git-sync-deploy] at $(git rev-parse --short HEAD) ($(git log -1 --format='%s'))"