chore: improve local deploy helper feedback

This commit is contained in:
Md Bayazid Bostame
2026-03-29 00:34:19 +01:00
parent b7a2d84b45
commit cd0c0ad65a
3 changed files with 16 additions and 4 deletions

View File

@@ -172,9 +172,11 @@ Use:
What it does: What it does:
1. requires the current branch to be `develop` 1. requires the current branch to be `develop`
2. fast-forwards from `origin/develop` 2. fast-forwards from `origin/develop`
3. syncs the repo to `/opt/workdock` via `rsync` 3. verifies that the server env file exists before syncing
4. runs the remote deployment script 4. syncs the repo to `/opt/workdock` via `rsync`
5. verifies the health endpoint 5. runs the remote deployment script
6. verifies the health endpoint
7. prints the deployed commit and branch
Important: Important:
- the helper preserves server-local env files: - the helper preserves server-local env files:

View File

@@ -385,7 +385,7 @@ make backup-verify BACKUP_DIR=backups/backup_YYYYmmdd_HHMMSS</code></pre>
<h3>Manual deploy</h3> <h3>Manual deploy</h3>
<p>The preferred current test-deployment path is the local helper script from a Mac or another LAN-connected workstation:</p> <p>The preferred current test-deployment path is the local helper script from a Mac or another LAN-connected workstation:</p>
<pre><code>./scripts/deploy_test_from_mac.sh</code></pre> <pre><code>./scripts/deploy_test_from_mac.sh</code></pre>
<p>This script fast-forwards <code>develop</code>, syncs the repo to the server with <code>rsync</code>, runs the remote deployment, and verifies the health endpoint.</p> <p>This script fast-forwards <code>develop</code>, checks that the remote env file exists, syncs the repo to the server with <code>rsync</code>, runs the remote deployment, verifies the health endpoint, and prints the deployed commit hash.</p>
<p>The script explicitly preserves server-local env files such as <code>.env.test</code> and <code>.env.prod</code> so deployment does not wipe machine-specific secrets.</p> <p>The script explicitly preserves server-local env files such as <code>.env.test</code> and <code>.env.prod</code> so deployment does not wipe machine-specific secrets.</p>
<p>Direct server-side deploy is still available if the code is already on the server:</p> <p>Direct server-side deploy is still available if the code is already on the server:</p>
<pre><code>cd /opt/workdock <pre><code>cd /opt/workdock

View File

@@ -23,6 +23,13 @@ fi
echo "Updating local branch from origin/develop..." echo "Updating local branch from origin/develop..."
git pull --ff-only 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} ..." echo "Syncing repository to ${DEPLOY_HOST}:${DEPLOY_PATH} ..."
rsync -az --delete \ rsync -az --delete \
--filter 'P .env.test' \ --filter 'P .env.test' \
@@ -44,4 +51,7 @@ $SSH_CMD "$DEPLOY_HOST" \
echo "Verifying health endpoint..." echo "Verifying health endpoint..."
curl --fail --silent --show-error --max-time 10 "$HEALTH_URL" >/dev/null 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 "Test deployment healthy: $HEALTH_URL"
echo "Deployed commit: $commit_sha"
echo "Branch: $current_branch"