fix: preserve .env across greenfield destroy
This commit is contained in:
parent
8366164155
commit
f9b1b3aa7b
1 changed files with 14 additions and 0 deletions
14
deploy.sh
14
deploy.sh
|
|
@ -43,6 +43,13 @@ go build -o "$BINARY_NAME" .
|
|||
# --- Greenfield path ---
|
||||
if [ "$GREENFIELD" = true ]; then
|
||||
echo "[3/6] Removing old deployment..."
|
||||
|
||||
# Preserve .env across greenfield destroy
|
||||
if [ -f "$TARGET_DIR/.env" ]; then
|
||||
cp "$TARGET_DIR/.env" /tmp/nextworkspace.env.bak
|
||||
echo "[INFO] Preserved .env"
|
||||
fi
|
||||
|
||||
rm -rf "$TARGET_DIR"
|
||||
|
||||
echo "[4/6] Creating target directories..."
|
||||
|
|
@ -52,6 +59,13 @@ if [ "$GREENFIELD" = true ]; then
|
|||
mkdir -p "$TARGET_DIR/compose"
|
||||
mkdir -p "$TARGET_DIR/logs"
|
||||
|
||||
# Restore preserved .env
|
||||
if [ -f /tmp/nextworkspace.env.bak ]; then
|
||||
mv /tmp/nextworkspace.env.bak "$TARGET_DIR/.env"
|
||||
chmod 600 "$TARGET_DIR/.env"
|
||||
echo "[INFO] Restored .env"
|
||||
fi
|
||||
|
||||
echo "[5/6] Copying binary..."
|
||||
cp "$BINARY_NAME" "$TARGET_DIR/$BINARY_NAME"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue