diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 07:37:03 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 07:37:03 +0000 |
| commit | 25251a1202c1311f07172881f7d7ada6af3f25cc (patch) | |
| tree | 31690c13dbae9b982fe131d27e0eda72afd4fc43 | |
| parent | 7b53b9e30e81aca67e98c8fce04674461da2c78d (diff) | |
feat: stash uncommitted changes before build in deploy script
Add --dirty flag to skip stashing behavior. Stashing includes untracked
files and uses a trap to ensure changes are popped back on exit.
| -rwxr-xr-x | scripts/deploy | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/scripts/deploy b/scripts/deploy index cc51fc1..5f730cc 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -1,18 +1,34 @@ #!/bin/bash # deploy — Build and deploy claudomator to /site/doot.terst.org -# Usage: ./scripts/deploy +# Usage: ./scripts/deploy [--dirty] # Example: sudo ./scripts/deploy set -euo pipefail +DIRTY=false +for arg in "$@"; do + if [ "$arg" == "--dirty" ]; then + DIRTY=true + fi +done + FQDN="doot.terst.org" SITE_DIR="/site/${FQDN}" BIN_DIR="${SITE_DIR}/bin" SERVICE="claudomator@${FQDN}.service" REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" -echo "==> Building claudomator..." cd "${REPO_DIR}" + +STASHED=false +if [ "$DIRTY" = false ] && [ -n "$(git status --porcelain)" ]; then + echo "==> Stashing uncommitted changes..." + git stash push -u -m "Auto-stash before deploy" + STASHED=true + trap 'if [ "$STASHED" = true ]; then echo "==> Popping stash..."; git stash pop; fi' EXIT +fi + +echo "==> Building claudomator..." export GOCACHE="${SITE_DIR}/cache/go-build" export GOPATH="${SITE_DIR}/cache/gopath" mkdir -p "${GOCACHE}" "${GOPATH}" |
