Enhance deployment script to force reset local changes and backup modified files
This commit is contained in:
13
.github/workflows/deploy.yml
vendored
13
.github/workflows/deploy.yml
vendored
@@ -43,10 +43,16 @@ jobs:
|
||||
"export REMOTE_DIR='${{ secrets.REMOTE_DIR }}'; bash -se" <<'EOF'
|
||||
set -euo pipefail
|
||||
cd "$REMOTE_DIR"
|
||||
# Reset any local changes if this is a git repository
|
||||
# Force reset any local changes regardless of git status
|
||||
if [ -d ".git" ]; then
|
||||
git reset --hard HEAD
|
||||
git clean -fd
|
||||
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
|
||||
else
|
||||
echo "No git repository found, creating backup of modified files..."
|
||||
# Backup any existing files that might conflict
|
||||
[ -f "docker-compose.yml" ] && cp docker-compose.yml docker-compose.yml.backup.$(date +%s) || true
|
||||
fi
|
||||
EOF
|
||||
|
||||
@@ -56,6 +62,7 @@ jobs:
|
||||
-e "ssh -p ${{ secrets.SSH_PORT }}" \
|
||||
--exclude ".git" \
|
||||
--exclude ".github" \
|
||||
--exclude ".env" \
|
||||
./ "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${REMOTE_DIR}/"
|
||||
|
||||
- name: Write .env on VPS (from GitHub Secrets)
|
||||
|
||||
Reference in New Issue
Block a user