CI/CD: gate deploys on tests and security, deploy the exact tested commit, verify and roll back #55
Open
opened 2026-11-22 15:26:41 -05:00 by jared
·
0 comments
No Branch/Tag Specified
main
kuma-token
modem-restart
modem-extras-screenshots
modem-extras
modem-login-screenshots
modem-login
pr-47-screenshots
polish
pr-46-screenshots
wan-health
pr-45-screenshots
attention-list
port-name-report
pr-44-screenshots
readme-power-polish
pr-42-screenshots
stale-outlet-watts
pr-41-screenshots
topology-polish
pr-40-screenshots
power-map
pr-39-screenshots
topology
pr-37-screenshots
stale-alerts
pr-36-screenshots
wan-incidents
pr-35-screenshots
unused-interfaces
pr-32-screenshots
loose-gear-on-top
tinker-create-action
revert-31
stale-interface-alerts
zimaboard-and-facing
pr-30-screenshots
pr-29-screenshots
pro-max-faceplates
rack-unlinked-port-clicks
pr-27-screenshots
rack-drawn-fronts
rack-panel-label
pr-25-screenshots
rack-rear-and-settings
pr-24-screenshots
racks-shelves-export
pr-23-screenshots
rack-view
pr-22-screenshots
inventory-and-faceplate-marks
pr-21-screenshots
events-history
ticket-recovery-and-context
pr-18-screenshots
deploy-2026.11.24-791
deploy-2026.11.24-782
deploy-2026.11.24-767
deploy-2026.11.20-757
deploy-2026.11.20-748
deploy-2026.11.19-733
deploy-2026.11.19-724
deploy-2026.11.18-715
deploy-2026.11.18-706
deploy-2026.11.18-697
deploy-2026.11.16-688
deploy-2026.11.15-678
deploy-2026.11.15-669
deploy-2026.11.15-660
deploy-2026.11.15-645
deploy-2026.11.15-636
deploy-2026.11.15-627
deploy-2026.11.15-618
deploy-2026.11.14-591
deploy-2026.11.14-582
deploy-2026.11.12-573
deploy-2026.11.11-564
deploy-2026.11.11-555
deploy-2026.11.11-552
deploy-2026.11.11-519
deploy-2026.11.11-501
deploy-2026.11.11-492
deploy-2026.11.11-483
deploy-2026.11.11-462
deploy-2026.11.11-453
deploy-2026.11.11-420
deploy-2026.11.11-411
deploy-2026.11.11-402
deploy-2026.11.11-393
deploy-2026.11.11-384
deploy-2026.11.11-375
deploy-2026.11.11-366
deploy-2026.11.10-357
deploy-2026.11.10-348
deploy-2026.11.10-333
deploy-2026.11.10-324
deploy-2026.11.07-314
deploy-2026.11.05-305
deploy-2026.11.05-296
deploy-2026.11.05-287
deploy-2026.10.03-273
deploy-2026.10.03-267
deploy-2026.09.05-260
deploy-2026.05.14-235
deploy-2026.05.14-232
deploy-2026.05.14-229
deploy-2026.05.13-226
deploy-2026.05.13-223
deploy-2026.05.13-220
deploy-2026.05.13-217
deploy-2026.05.13-214
deploy-2026.05.13-211
deploy-2026.05.13-208
deploy-2026.05.13-202
deploy-2026.05.12-199
deploy-2026.05.12-196
deploy-2026.05.12-193
deploy-2026.05.12-190
deploy-2026.05.11-187
deploy-2026.05.11-184
deploy-2026.05.11-181
deploy-2026.05.11-178
deploy-2026.05.11-175
deploy-2026.05.11-172
deploy-2026.05.11-169
deploy-2026.05.11-166
deploy-2026.05.11-163
deploy-2026.05.11-160
deploy-2026.05.11-132
deploy-2026.05.11-129
deploy-2026.05.11-126
deploy-2026.05.11-123
deploy-2026.05.11-120
deploy-2026.05.11-117
deploy-2026.05.11-114
deploy-2026.05.11-111
deploy-2026.05.11-108
deploy-2026.05.11-105
deploy-2026.05.11-102
deploy-2026.05.11-99
deploy-2026.05.11-96
deploy-2026.05.11-93
deploy-2026.05.11-90
deploy-2026.05.11-87
deploy-2026.05.11-84
deploy-2026.05.07-81
deploy-2026.05.07-78
deploy-2026.05.01-74
deploy-2026.05.01-71
deploy-2026.05.01-68
deploy-2026.05.01-65
deploy-2026.05.01-62
deploy-2026.05.01-59
deploy-2026.05.01-56
deploy-2026.04.30-53
deploy-2026.04.29-50
deploy-2026.04.26-46
Labels
No items
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: LotusGuild/gandalf#55
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This came out of the CI/CD work on Pulse (LotusGuild/pulse#45). Pulse's pipeline is in
.gitea/workflows/ci.ymlthere, and its server-side deploy script isdeploy/pulse_deploy.sh. The proven pieces can be copied from both.Problems in Gandalf's CI today
lint.yml,deployhasneeds: [python-lint, js-lint]. pytest (test.yml) and bandit (security.yml) are separate workflows, so a commit with failing tests or a bandit finding still deploys.{"ref"}:mainis when the hook runs, not the commit CI tested;actions/checkout@v3is a moving tag, and old.npm install eslint@8doesn't use the lockfile, and flake8, bandit and pytest are pip-installed unpinned. The Python version comes from whatever the runner image has, and may differ from production.mainsend nothing.Fixes that worked in Pulse
One
ci.yml: jobs lint, test, security and deploy, withdeployneeding all checks, plus a notify job. Permissionscontents: readby default andcontents: writeonly on deploy. Aconcurrencygroup so deploys queue and are never cancelled mid-way.Pinned actions and tools: actions pinned to full SHAs, e.g.
actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0. Pinned versions of flake8, bandit and pytest (arequirements-dev.txt).npm ci.Pin the job image (runner quirk): set
container: python:3.X-bookwormto production's Python version, instead of apt-installing Python on each run.actions/setup-pythonorsetup-node. The runner shares one tool cache volume between concurrent jobs, and parallel setup actions overwrite each other's installs. That broke Pulse's CI twice.Deploy the exact sha (
pulse_deploy.shpattern):{"ref","sha","ts"}, HMAC-signed.shaandtsto the script viapass-arguments-to-command.tsthat isn't newer than the last accepted one (replay protection).origin/main, thengit checkout --detach <sha>, installs, restarts and polls a health endpoint for that sha, and rolls back to the previous commit if it never reports healthy.deploy-*./healthz(or similar) that returns the running git sha. Pulse reads it once at startup withgit rev-parse HEAD.Scan job:
fetch-depth: 0,--redact);.gitea/workflows/*.yml;*.sh.Tool downloads are pinned and checked with SHA-256. Run a local dry run first so the job starts green.
Branch protection: require every check, using the job names as
CI / <job name> (push).Pulse doesn't depend on any of this; it's just parity. No changes to Pulse's API are involved.