gandalf#55, part 2 (the server side; needs installing on CT 157).
deploy/gandalf_deploy.sh <sha> <ts>, run by the gandalf-deploy webhook
from its installed copy /usr/local/bin/gandalf_app_deploy.sh:
- refuses a request signed more than 5 minutes ago, or one not newer
than the last accepted (replay), and any sha not on origin/main;
- checks out exactly that sha (detached), installs requirements.txt and
restarts gandalf and gandalf-monitor;
- waits for /health to report the sha for both with status ok, and rolls
back to the previous commit otherwise; one deploy at a time (flock).
tests/test_deploy_script.py runs the real script in a sandbox with fake
systemctl, pip3 and curl: exact commit, untracked config.json kept,
replay, stale, off-main and malformed requests refused, an unhealthy
build rolled back, and the running commit a no-op.
Co-Authored-By: Claude Opus 5.5 <[email protected]>