Files
musadeq/sync-to-server.sh
2026-04-16 23:48:59 +03:00

54 lines
2.1 KiB
Bash
Executable File

#!/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="root"
SERVER_IP="194.163.173.157" # Contabo VPS
PROJECT_DIR="/home/intaleqapp-musadeq/htdocs"
echo "🌐 Synchronizing with production server ($SERVER_IP)..."
ssh $SERVER_USER@$SERVER_IP << EOF
mkdir -p $PROJECT_DIR
cd $PROJECT_DIR
if [ ! -d ".git" ]; then
echo "🌑 Initializing production repository (First time)..."
git clone https://git.intaleqapp.com/Hamza/musadeq.git .
else
echo "⬇️ Pulling latest changes from Git..."
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!"