Files
SkyMoney/.gitea/workflows/deploy.yml
Ricearoni1245 d9df9b0fe4
Some checks failed
Security Tests / security-non-db (push) Successful in 18s
Security Tests / security-db (push) Successful in 23s
Deploy / deploy (push) Has been cancelled
fix: adding db recovery practices (bye bye db)
2026-03-02 11:16:52 -06:00

78 lines
2.1 KiB
YAML

name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: vps-host
steps:
- uses: actions/checkout@v4.2.2
- name: Supply chain checks (production dependencies)
run: |
set -euo pipefail
cd api
npm ci
npm audit --omit=dev --audit-level=high
cd ../web
npm ci
npm audit --omit=dev --audit-level=high
- name: Build Web
run: |
cd web
npm run build
- name: Deploy with Docker Compose
run: |
set -euo pipefail
# Deploy directory
APP_DIR=/opt/skymoney
mkdir -p $APP_DIR
# Sync repo to server (excluding node_modules, dist, etc)
rsync -a --delete \
--exclude=node_modules \
--exclude=dist \
--exclude=.git \
--exclude=.gitea \
--exclude=backups \
--exclude=exporting \
./ $APP_DIR/
# Copy built web to shared volume
mkdir -p /var/www/skymoney/dist
cp -r web/dist/* /var/www/skymoney/dist/
cd $APP_DIR
# Keep a stable compose project name to avoid accidental new resource names
export COMPOSE_PROJECT_NAME=skymoney
# Validate migration target before touching containers
export EXPECTED_PROD_DB_HOST="${EXPECTED_PROD_DB_HOST:-postgres}"
export EXPECTED_PROD_DB_NAME="${EXPECTED_PROD_DB_NAME:-skymoney}"
./scripts/validate-prod-db-target.sh
# Build and start all services
sudo -E docker-compose up -d --build
# Wait for database to be ready
sleep 10
# Mandatory pre-migration backup
BACKUP_ENFORCE_TARGET_CHECK=1 \
EXPECTED_PROD_DB_HOST="$EXPECTED_PROD_DB_HOST" \
EXPECTED_PROD_DB_NAME="$EXPECTED_PROD_DB_NAME" \
BACKUP_DIR=/opt/skymoney/backups \
./scripts/backup.sh
# Run Prisma migrations inside the API container
sudo -E docker-compose exec -T api npx prisma migrate deploy
- name: Reload Nginx
run: sudo systemctl reload nginx