Add watch-deploy script for automatic rebuild and redeploy on src changes
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
31
artifacts/dental-app/scripts/watch-deploy.sh
Executable file
31
artifacts/dental-app/scripts/watch-deploy.sh
Executable file
@@ -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
|
||||||
Reference in New Issue
Block a user