#!/bin/bash # Safe Deployment Script for VisaBerry / QuickTools echo "๐Ÿš€ Starting Safe Deployment Process..." # 1. Run Backend Unit Tests echo "๐Ÿงช Running Backend Tests..." cd backend if venv/bin/pytest test_main.py; then echo "โœ… Tests Passed!" else echo "โŒ Tests Failed! Deployment Aborted." exit 1 fi cd .. # 2. Build Frontend echo "๐Ÿ—๏ธ Building Frontend..." cd frontend rm -rf .next if npm run build; then echo "โœ… Build Successful!" else echo "โŒ Build Failed! Deployment Aborted." exit 1 fi # 3. Zero-Downtime Reload via PM2 echo "๐Ÿ”„ Reloading Services..." pm2 reload visa-frontend # Backend is usually fast, restart is fine, or also reload if using gunicorn pm2 restart visa-backend echo "โœจ Deployment Complete! VisaBerry is live and stable."