From 072d7496d8f8974333336fedfaeb48553f7871c7 Mon Sep 17 00:00:00 2001 From: Gitead Date: Sat, 1 Aug 2026 11:08:00 -0400 Subject: [PATCH] Add watch-deploy script for automatic rebuild and redeploy on src changes Co-Authored-By: Claude Sonnet 5 --- artifacts/dental-app/scripts/watch-deploy.sh | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 artifacts/dental-app/scripts/watch-deploy.sh diff --git a/artifacts/dental-app/scripts/watch-deploy.sh b/artifacts/dental-app/scripts/watch-deploy.sh new file mode 100755 index 0000000..4646598 --- /dev/null +++ b/artifacts/dental-app/scripts/watch-deploy.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Watches src/ for changes and automatically rebuilds + redeploys the +# static site to /var/www/app.mydentalofficemanagement.com. +set -euo pipefail + +cd "$(dirname "$0")/.." + +DEPLOY_DIR="/var/www/app.mydentalofficemanagement.com" + +build_and_deploy() { + echo "[watch-deploy] change detected, rebuilding..." + if PORT=5173 BASE_PATH=/ npm run build; then + find "${DEPLOY_DIR:?}" -mindepth 1 -delete + cp -r dist/public/* "$DEPLOY_DIR"/ + echo "[watch-deploy] deployed at $(date)" + else + echo "[watch-deploy] build failed, not deploying" + fi +} + +build_and_deploy + +while true; do + inotifywait -r -e modify,create,delete,move --exclude '(^|/)\.' src/ >/dev/null 2>&1 + # debounce: wait for rapid successive saves to settle + sleep 1 + while inotifywait -t 1 -r -e modify,create,delete,move --exclude '(^|/)\.' src/ >/dev/null 2>&1; do + sleep 1 + done + build_and_deploy +done