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