Enhance deployment script to force reset local changes and pull latest from main branch

This commit is contained in:
Mohmmed Elfateh Sabry
2025-08-11 16:00:43 +03:00
parent 97f5ec4fbc
commit 43e25f7140

View File

@@ -42,12 +42,12 @@ jobs:
"export REMOTE_DIR='${{ secrets.REMOTE_DIR }}'; bash -se" <<'EOF'
set -euo pipefail
cd "$REMOTE_DIR"
# Force reset any local changes regardless of git status
# Force reset any local changes and pull latest
if [ -d ".git" ]; then
echo "Git repository detected, resetting changes..."
git reset --hard HEAD 2>/dev/null || true
git clean -fd 2>/dev/null || true
git checkout main 2>/dev/null || git checkout master 2>/dev/null || true
echo "Git repository detected, resetting and pulling..."
git reset --hard HEAD
git clean -fd
git pull origin main
else
echo "No git repository found, creating backup of modified files..."
# Backup any existing files that might conflict