Files
nabeh/deploy.sh
2026-05-21 00:40:47 +03:00

58 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# --- Configuration ---
SERVER_USER="root"
SERVER_IP="194.163.173.157"
SERVER_PATH="/home/intaleqapp-nabeh/htdocs/nabeh.intaleqapp.com"
GIT_BRANCH="main"
# Colors for terminal styling
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${GREEN}🚀 Starting Nabeh Sync & Deploy...${NC}"
# 1. Commit local changes automatically (with date/time or custom message)
if [ -n "$(git status --porcelain)" ]; then
COMMIT_MSG=${1:-"Deploy: $(date '+%Y-%m-%d %H:%M:%S')"}
echo -e "${YELLOW}Staging and committing changes with message: ${COMMIT_MSG}${NC}"
git add .
git commit -m "$COMMIT_MSG"
echo -e "${GREEN}✅ Local commit created successfully!${NC}"
else
echo -e " No local changes to commit."
fi
# 2. Push to Git Remote
echo -e "${GREEN}📤 Pushing changes to remote repository (${GIT_BRANCH})...${NC}"
git push origin "$GIT_BRANCH"
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Git Push failed! Deployment aborted.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Successfully pushed to remote repository!${NC}"
# 3. Connect to server via SSH and pull updates
echo -e "${GREEN}🌐 Connecting to server and pulling updates...${NC}"
ssh -o ConnectTimeout=5 "${SERVER_USER}@${SERVER_IP}" "
cd ${SERVER_PATH} && \
git pull origin ${GIT_BRANCH} && \
if [ -f 'backend/composer.json' ]; then
echo '📦 Updating composer dependencies on server...' && \
cd backend && \
composer install --no-dev --optimize-autoloader
fi
"
if [ $? -eq 0 ]; then
echo -e "${GREEN}==========================================${NC}"
echo -e "✨ Nabeh deployment synced perfectly! "
echo -e "==========================================${NC}"
else
echo -e "${RED}❌ Server update failed! Check your connection or SSH setup.${NC}"
exit 1
fi