fix(deploy): Backup and restore .ssh keys during git-based deployments
SSH keys for mail server management are not in git, need to preserve them like .envs secrets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
17
deploy.sh
17
deploy.sh
@@ -83,6 +83,16 @@ elif [ -d "$REMOTE_DIR/.envs" ]; then
|
|||||||
cp -r "$REMOTE_DIR/.envs" /tmp/.envs-backup
|
cp -r "$REMOTE_DIR/.envs" /tmp/.envs-backup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Backup .ssh if it exists (SSH keys not in git)
|
||||||
|
if [ -d "$REMOTE_DIR/smoothschedule/.ssh" ]; then
|
||||||
|
echo ">>> Backing up .ssh keys..."
|
||||||
|
cp -r "$REMOTE_DIR/smoothschedule/.ssh" /tmp/.ssh-backup
|
||||||
|
elif [ -d "$REMOTE_DIR/.ssh" ]; then
|
||||||
|
# Old structure
|
||||||
|
echo ">>> Backing up .ssh keys (old location)..."
|
||||||
|
cp -r "$REMOTE_DIR/.ssh" /tmp/.ssh-backup
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d "$REMOTE_DIR/.git" ]; then
|
if [ ! -d "$REMOTE_DIR/.git" ]; then
|
||||||
echo ">>> Cloning repository for the first time..."
|
echo ">>> Cloning repository for the first time..."
|
||||||
# Remove old non-git deployment if exists
|
# Remove old non-git deployment if exists
|
||||||
@@ -106,6 +116,13 @@ if [ -d /tmp/.envs-backup ]; then
|
|||||||
rm -rf /tmp/.envs-backup
|
rm -rf /tmp/.envs-backup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore .ssh keys
|
||||||
|
if [ -d /tmp/.ssh-backup ]; then
|
||||||
|
echo ">>> Restoring .ssh keys..."
|
||||||
|
cp -r /tmp/.ssh-backup "$REMOTE_DIR/smoothschedule/.ssh"
|
||||||
|
rm -rf /tmp/.ssh-backup
|
||||||
|
fi
|
||||||
|
|
||||||
echo ">>> Current commit:"
|
echo ">>> Current commit:"
|
||||||
git log -1 --oneline
|
git log -1 --oneline
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user