From cd0c0ad65ac71c69c7831f8d3896257582f793d6 Mon Sep 17 00:00:00 2001 From: Md Bayazid Bostame Date: Sun, 29 Mar 2026 00:34:19 +0100 Subject: [PATCH] chore: improve local deploy helper feedback --- DEPLOYMENT.md | 8 +++++--- .../templates/workflows/developer_handbook.html | 2 +- scripts/deploy_test_from_mac.sh | 10 ++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 1d39405..4d45bcd 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -172,9 +172,11 @@ Use: What it does: 1. requires the current branch to be `develop` 2. fast-forwards from `origin/develop` -3. syncs the repo to `/opt/workdock` via `rsync` -4. runs the remote deployment script -5. verifies the health endpoint +3. verifies that the server env file exists before syncing +4. syncs the repo to `/opt/workdock` via `rsync` +5. runs the remote deployment script +6. verifies the health endpoint +7. prints the deployed commit and branch Important: - the helper preserves server-local env files: diff --git a/backend/workflows/templates/workflows/developer_handbook.html b/backend/workflows/templates/workflows/developer_handbook.html index f78f29c..d72a959 100644 --- a/backend/workflows/templates/workflows/developer_handbook.html +++ b/backend/workflows/templates/workflows/developer_handbook.html @@ -385,7 +385,7 @@ make backup-verify BACKUP_DIR=backups/backup_YYYYmmdd_HHMMSS

Manual deploy

The preferred current test-deployment path is the local helper script from a Mac or another LAN-connected workstation:

./scripts/deploy_test_from_mac.sh
-

This script fast-forwards develop, syncs the repo to the server with rsync, runs the remote deployment, and verifies the health endpoint.

+

This script fast-forwards develop, checks that the remote env file exists, syncs the repo to the server with rsync, runs the remote deployment, verifies the health endpoint, and prints the deployed commit hash.

The script explicitly preserves server-local env files such as .env.test and .env.prod so deployment does not wipe machine-specific secrets.

Direct server-side deploy is still available if the code is already on the server:

cd /opt/workdock
diff --git a/scripts/deploy_test_from_mac.sh b/scripts/deploy_test_from_mac.sh
index 0cf80aa..817a112 100755
--- a/scripts/deploy_test_from_mac.sh
+++ b/scripts/deploy_test_from_mac.sh
@@ -23,6 +23,13 @@ fi
 echo "Updating local branch from origin/develop..."
 git pull --ff-only origin develop
 
+echo "Checking remote env file..."
+$SSH_CMD "$DEPLOY_HOST" "test -f '$DEPLOY_PATH/$REMOTE_ENV_FILE'" || {
+  echo "Missing remote env file: $DEPLOY_PATH/$REMOTE_ENV_FILE" >&2
+  echo "Create or restore the server env file before deploying." >&2
+  exit 1
+}
+
 echo "Syncing repository to ${DEPLOY_HOST}:${DEPLOY_PATH} ..."
 rsync -az --delete \
   --filter 'P .env.test' \
@@ -44,4 +51,7 @@ $SSH_CMD "$DEPLOY_HOST" \
 
 echo "Verifying health endpoint..."
 curl --fail --silent --show-error --max-time 10 "$HEALTH_URL" >/dev/null
+commit_sha="$(git rev-parse --short HEAD)"
 echo "Test deployment healthy: $HEALTH_URL"
+echo "Deployed commit: $commit_sha"
+echo "Branch: $current_branch"