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'
|
"export REMOTE_DIR='${{ secrets.REMOTE_DIR }}'; bash -se" <<'EOF'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "$REMOTE_DIR"
|
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
|
if [ -d ".git" ]; then
|
||||||
git reset --hard HEAD
|
echo "Git repository detected, resetting changes..."
|
||||||
git clean -fd
|
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
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -56,6 +62,7 @@ jobs:
|
|||||||
-e "ssh -p ${{ secrets.SSH_PORT }}" \
|
-e "ssh -p ${{ secrets.SSH_PORT }}" \
|
||||||
--exclude ".git" \
|
--exclude ".git" \
|
||||||
--exclude ".github" \
|
--exclude ".github" \
|
||||||
|
--exclude ".env" \
|
||||||
./ "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${REMOTE_DIR}/"
|
./ "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${REMOTE_DIR}/"
|
||||||
|
|
||||||
- name: Write .env on VPS (from GitHub Secrets)
|
- name: Write .env on VPS (from GitHub Secrets)
|
||||||
|
|||||||
Reference in New Issue
Block a user