forked from syntaxbullet/aurorabot
chore: improve DX scripts, fix test suite, and harden tooling
Scripts: - remote.sh: remove unused open_browser() function - deploy-remote.sh: add DB backup before deploy, --skip-backup flag, step numbering - db-backup.sh: fix macOS compat (xargs -r is GNU-only), use portable approach - db-restore.sh: add safety backup before restore, SQL file validation, file size display - logs.sh: default to no-follow with --tail=100, order-independent arg parsing - docker-cleanup.sh: add Docker health check, colored output - test-sequential.sh: exclude *.integration.test.ts by default, add --integration flag - simulate-ci.sh: pass --integration flag (has real DB) Tests: - db.test.ts: fix mock path from ./DrizzleClient to @shared/db/DrizzleClient - server.settings.test.ts: rewrite mocks for gameSettingsService (old config/saveConfig removed) - server.test.ts: add missing config.lootdrop and BotClient mocks, complete DrizzleClient chain - indexes.test.ts: rename to indexes.integration.test.ts (requires live DB) Config: - package.json: test script uses sequential runner, add test:ci and db:restore aliases - deploy.yml: use --integration flag in CI (has Postgres service)
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Aurora Remote Deployment Script
|
||||
# =============================================================================
|
||||
# Deploys the application to a remote VPS via SSH.
|
||||
# Performs a database backup, pulls latest code, builds, and restarts services.
|
||||
#
|
||||
# Usage: ./deploy-remote.sh [--skip-backup]
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Load environment variables
|
||||
@@ -8,8 +17,14 @@ if [ -f .env ]; then
|
||||
set +a
|
||||
fi
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
if [ -z "$VPS_HOST" ] || [ -z "$VPS_USER" ]; then
|
||||
echo "Error: VPS_HOST and VPS_USER must be set in .env"
|
||||
echo -e "${RED}Error: VPS_HOST and VPS_USER must be set in .env${NC}"
|
||||
echo "Please add them to your .env file:"
|
||||
echo "VPS_USER=your-username"
|
||||
echo "VPS_HOST=your-ip-address"
|
||||
@@ -18,15 +33,36 @@ fi
|
||||
|
||||
# Default remote directory to ~/Aurora if not specified
|
||||
REMOTE_DIR="${VPS_PROJECT_PATH:-~/Aurora}"
|
||||
SKIP_BACKUP=false
|
||||
|
||||
echo -e "\033[1;33m🚀 Deploying to $VPS_USER@$VPS_HOST:$REMOTE_DIR...\033[0m"
|
||||
if [[ "$1" == "--skip-backup" ]]; then
|
||||
SKIP_BACKUP=true
|
||||
fi
|
||||
|
||||
# Execute commands on remote server
|
||||
ssh -t "$VPS_USER@$VPS_HOST" "cd $REMOTE_DIR && \
|
||||
echo '⬇️ Pulling latest changes...' && \
|
||||
git pull && \
|
||||
echo '🏗️ Building production containers...' && \
|
||||
docker compose -f docker-compose.prod.yml build && \
|
||||
echo '🚀 Starting services...' && \
|
||||
docker compose -f docker-compose.prod.yml up -d && \
|
||||
echo '✅ Deployment complete!'"
|
||||
echo -e "${YELLOW}🚀 Deploying to $VPS_USER@$VPS_HOST:$REMOTE_DIR...${NC}"
|
||||
|
||||
# Step 1: Database backup (unless skipped)
|
||||
if [ "$SKIP_BACKUP" = false ]; then
|
||||
echo -e "\n${YELLOW}💾 Step 1/4: Backing up remote database...${NC}"
|
||||
ssh -t "$VPS_USER@$VPS_HOST" "cd $REMOTE_DIR && bash shared/scripts/db-backup.sh" || {
|
||||
echo -e "${RED}⚠️ Backup failed. Aborting deployment.${NC}"
|
||||
echo "Use --skip-backup to deploy without backing up."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo -e "\n${YELLOW}⏭️ Step 1/4: Skipping database backup (--skip-backup)${NC}"
|
||||
fi
|
||||
|
||||
# Step 2: Pull latest code
|
||||
echo -e "\n${YELLOW}⬇️ Step 2/4: Pulling latest changes...${NC}"
|
||||
ssh -t "$VPS_USER@$VPS_HOST" "cd $REMOTE_DIR && git pull"
|
||||
|
||||
# Step 3: Build production containers
|
||||
echo -e "\n${YELLOW}🏗️ Step 3/4: Building production containers...${NC}"
|
||||
ssh -t "$VPS_USER@$VPS_HOST" "cd $REMOTE_DIR && docker compose -f docker-compose.prod.yml build"
|
||||
|
||||
# Step 4: Restart services
|
||||
echo -e "\n${YELLOW}🚀 Step 4/4: Starting services...${NC}"
|
||||
ssh -t "$VPS_USER@$VPS_HOST" "cd $REMOTE_DIR && docker compose -f docker-compose.prod.yml up -d"
|
||||
|
||||
echo -e "\n${GREEN}✅ Deployment complete!${NC}"
|
||||
|
||||
Reference in New Issue
Block a user