#!/bin/bash # ============================================================================ # POUNCE DEPLOY SCRIPT # Commits all changes and deploys to server # ============================================================================ set -e # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' RED='\033[0;31m' NC='\033[0m' # No Color # Server config SERVER_USER="user" SERVER_HOST="10.42.0.73" SERVER_PATH="/home/user/pounce" SERVER_PASS="user" echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}" echo -e "${BLUE} POUNCE DEPLOY SCRIPT ${NC}" echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}" # Get commit message if [ -z "$1" ]; then COMMIT_MSG="Deploy: $(date '+%Y-%m-%d %H:%M')" else COMMIT_MSG="$1" fi echo -e "\n${YELLOW}[1/5] Staging changes...${NC}" git add -A echo -e "\n${YELLOW}[2/5] Committing: ${COMMIT_MSG}${NC}" git commit -m "$COMMIT_MSG" || echo "Nothing to commit" echo -e "\n${YELLOW}[3/5] Pushing to git.6bit.ch...${NC}" git push origin main echo -e "\n${YELLOW}[4/5] Syncing files to server...${NC}" # Sync frontend sshpass -p "$SERVER_PASS" rsync -avz --delete \ --exclude 'node_modules' \ --exclude '.next' \ --exclude '.git' \ frontend/ $SERVER_USER@$SERVER_HOST:$SERVER_PATH/frontend/ # Sync backend sshpass -p "$SERVER_PASS" rsync -avz --delete \ --exclude '__pycache__' \ --exclude '.pytest_cache' \ --exclude 'venv' \ --exclude '.git' \ --exclude '*.pyc' \ backend/ $SERVER_USER@$SERVER_HOST:$SERVER_PATH/backend/ echo -e "\n${YELLOW}[5/5] Building and restarting on server...${NC}" sshpass -p "$SERVER_PASS" ssh $SERVER_USER@$SERVER_HOST << 'EOF' cd ~/pounce # Build frontend echo "Building frontend..." cd frontend npm run build 2>&1 | tail -10 cd .. # Restart services echo "Restarting services..." ./start.sh 2>&1 | tail -5 EOF echo -e "\n${GREEN}═══════════════════════════════════════════════════════════════${NC}" echo -e "${GREEN} ✅ DEPLOY COMPLETE! ${NC}" echo -e "${GREEN}═══════════════════════════════════════════════════════════════${NC}" echo -e "\nFrontend: ${BLUE}http://$SERVER_HOST:3000${NC}" echo -e "Backend: ${BLUE}http://$SERVER_HOST:8000${NC}"