#!/usr/bin/env bash # Build locally, push to the droplet, restart. Usage: deploy/deploy.sh set -euo pipefail HOST="${1:?usage: deploy.sh }" npm run build --workspace=@wizwar/web # Old hashed chunks stay a week: a page loaded before this deploy can still # fetch the module it was built against instead of failing mid-game. rsync -az --delete --filter='P packages/web/dist/assets/*' \ --exclude node_modules --exclude data/ --exclude .git --exclude research \ ./ "root@$HOST:/opt/wizwar/" ssh "root@$HOST" ' cd /opt/wizwar && npm install --no-audit --no-fund find /opt/wizwar/packages/web/dist/assets -type f -mtime +7 -delete chown -R wizwar:wizwar /opt/wizwar cp /opt/wizwar/deploy/wizwar.service /etc/systemd/system/wizwar.service # Cron runs the backup and the rollup from /usr/local/bin: install # them on every deploy so the live copies are always the repo copies. install -m 755 /opt/wizwar/deploy/wizwar-backup.sh /usr/local/bin/wizwar-backup.sh install -m 755 /opt/wizwar/deploy/wizwar-rollup.sh /usr/local/bin/wizwar-rollup.sh install -m 755 /opt/wizwar/deploy/wizwar-visitors.sh /usr/local/bin/wizwar-visitors.sh install -m 644 /opt/wizwar/deploy/wizwar-rollup.cron /etc/cron.d/wizwar-rollup systemctl daemon-reload systemctl enable --now wizwar systemctl restart wizwar systemctl --no-pager -l status wizwar | head -5 ' echo "deployed."