Files
hope-events/scripts/deploy.sh
T
joshuaandClaude Opus 5.5 48660732fe Run background jobs on a pg-boss queue; add e2e tests, CI and deploy script
Timed jobs move from in-process timers to a job registry run by pg-boss:
once per schedule across processes, retries, run history, cron schedules
in the church timezone, and an admin Background jobs page with Run now.
Playwright end-to-end tests run against their own seeded database. A
Gitea Actions workflow runs backend tests, frontend checks and the e2e
tests, and deploys v* tags with scripts/deploy.sh once secrets are set.
Also fixes the at-the-door check-in count for multi-day tickets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 15:49:46 +02:00

41 lines
1.5 KiB
Bash

#!/usr/bin/env bash
# Updates this install to a tagged release: back up the database, check out the tag,
# install, migrate, build, and reload PM2. If anything fails before the reload, the
# previous version keeps running and the checkout goes back to it.
#
# Usage (on the server, from the repo folder): bash scripts/deploy.sh v1.34.0
# CI runs this over SSH when a v* tag is pushed (see .gitea/workflows/ci.yml).
set -euo pipefail
TAG="${1:?Usage: scripts/deploy.sh <tag>}"
cd "$(dirname "$0")/.."
PREVIOUS="$(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)"
echo "==> Deploying $TAG (currently $PREVIOUS)"
echo "==> Backing up the database"
(cd backend && node -e "require('dotenv').config(); require('./src/utils/backupUtils').runBackup().then(r => console.log(' ', r.filename)).catch(e => { console.error(' Backup failed:', e.message); process.exit(1); })")
rollback() {
echo "!!> Deploy failed — going back to $PREVIOUS (the running version was not touched)"
git checkout -q "$PREVIOUS"
(cd backend && npm ci --silent) || true
(cd frontend && npm ci --silent && npm run build --silent) || true
}
trap rollback ERR
git fetch --tags --quiet origin
git checkout -q "$TAG"
echo "==> Backend: install and migrate"
(cd backend && npm ci && npm run prisma:deploy)
echo "==> Frontend: install and build"
(cd frontend && npm ci && npm run build)
trap - ERR
echo "==> Reloading PM2"
pm2 reload ecosystem.config.js --update-env
echo "==> Deployed $TAG"