profile/scripts/deploy-site.sh
ilia b523b67587 chore(deploy): server script to reset main, npm ci, build, rsync dist
- Hard reset to origin/main so local package edits cannot block pulls
- Optional rsync to SITE_ROOT (default /var/www/iliadobkin.com) if dir exists
- engines.node >=20.19, .nvmrc 22 for Vite 7

Made-with: Cursor
2026-03-24 23:27:54 -04:00

37 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Run on the production host from the repo clone (e.g. /var/www/iliadobkin.com-src).
# Fixes stuck deploys: local edits to package.json / lockfile block git pull — this resets to origin/main.
#
# Requires Node >= 20.19 (see .nvmrc). Example: nvm install && nvm use
#
# Optional: SITE_ROOT=/var/www/iliadobkin.com (default). Rsync runs only if that directory exists.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_ROOT"
SITE_ROOT="${SITE_ROOT:-/var/www/iliadobkin.com}"
echo "==> Node $(node -v) (Vite 7 needs 20.19+ or 22.12+)"
echo "==> Git: match origin/main exactly (drops local changes to tracked files)"
git fetch origin
git checkout main
git reset --hard origin/main
echo "==> Dependencies (clean)"
rm -rf node_modules
npm ci
echo "==> Build"
npm run build
if [[ -d "$SITE_ROOT" ]]; then
echo "==> Publish dist/ -> $SITE_ROOT/"
rsync -av --delete "${REPO_ROOT}/dist/" "${SITE_ROOT}/"
echo "==> Done. Reload nginx if needed: systemctl reload nginx"
else
echo "WARN: SITE_ROOT '$SITE_ROOT' is not a directory — not copying dist."
echo " Set SITE_ROOT to your nginx root, or copy ${REPO_ROOT}/dist/ manually."
fi