Files
newbury-exhibit/deploy.sh
T
2026-06-29 06:53:35 +00:00

34 lines
974 B
Bash
Executable File

#!/usr/bin/env bash
# Newbury Exhibit — deploy box runner (pull-only, never pushes).
# Forces local working copy to match origin/dev, then (re)starts the server.
set -e
BRANCH=dev
PORT=${PORT:-34034}
cd "$(dirname "$0")"
echo "== Fetching origin/$BRANCH =="
git fetch origin "$BRANCH"
echo "== Forcing working copy to origin/$BRANCH (discards any local changes) =="
git reset --hard "origin/$BRANCH"
# install deps only if package files changed since last run
if [ package.json -nt .deploy-installed ] || [ package-lock.json -nt .deploy-installed ] || [ ! -f .deploy-installed ]; then
echo "== Installing dependencies =="
npm install --no-audit --no-fund
touch .deploy-installed
else
echo "== Dependencies unchanged, skipping npm install =="
fi
# free the port if something is already on it
if command -v fuser >/dev/null 2>&1; then
fuser -k ${PORT}/tcp 2>/dev/null || true
sleep 1
fi
echo "== Starting server on port ${PORT} =="
PORT=${PORT} npm start