#!/bin/bash # ════════════════════════════════════════════════════════════ # مُصادَق (Musadaq) — Production Synchronization Script # ════════════════════════════════════════════════════════════ # Usage: ./sync-to-server.sh "Your commit message" # ════════════════════════════════════════════════════════════ COMMIT_MESSAGE=$1 if [ -z "$COMMIT_MESSAGE" ] then COMMIT_MESSAGE="🚀 Musadaq deployment sync: $(date)" fi # ── 1. Push to Git ────────────────────────────────────────── echo "📤 Pushing changes to remote repository..." git add . git commit -m "$COMMIT_MESSAGE" git push origin main # ── 2. Deploy to Production ───────────────────────────────── # Update the variables below with your VPS credentials SERVER_USER="musadaq" SERVER_IP="194.163.173.157" # Contabo VPS PROJECT_DIR="/home/intaleqapp-musadeq/htdocs/musadeq.intaleqapp.com" echo "🌐 Synchronizing with production server ($SERVER_IP)..." ssh $SERVER_USER@$SERVER_IP << EOF cd $PROJECT_DIR git config --global --add safe.directory $PROJECT_DIR if [ ! -d ".git" ]; then echo "🌑 Initializing production repository (Force setup in non-empty dir)..." git init git config --global --add safe.directory $PROJECT_DIR git remote add origin https://git.intaleqapp.com/Hamza/musadeq.git git fetch --all git reset --hard origin/main else echo "⬇️ Pulling latest changes from Git..." # In case remote was lost or ownership changed git remote add origin https://git.intaleqapp.com/Hamza/musadeq.git 2>/dev/null git pull origin main fi if [ -f "docker-compose.yml" ]; then echo "🏗️ Rebuilding production containers (Docker Compose)..." docker compose up -d --build else echo "❌ Error: docker-compose.yml not found on server!" exit 1 fi echo "✅ Deployment successful at \$(date)!" EOF echo "✨ Sync completed successfully!"