Architecture portfolio

ADR 002

Push-to-deploy with one locked key per app

AcceptedNovember 2026Scope: CI/CD, all apps

Context

Every app should deploy automatically when main changes. Git must be the only source of truth, with no hand edits on the server. CI systems are a common attack path, though. A leaked CI secret that gives a shell on the production host would expose every app and every database.

Options considered

OptionForAgainst
One shared CI SSH key with a shellSimplestOne leak means root-equivalent access to everything
Pull-based agent on the host (Watchtower, Argo-style)No inbound access from CINeeds registry credentials on the host and adds another always-on component; harder to see deploy results in CI
Webhook receiver on the hostNo SSHA new public endpoint to harden and authenticate
One SSH key per app, locked with a forced commandCI shows the deploy and health-check result; a leaked key can only redeploy that app's current mainKeys need rotating; setup takes a small privileged script

Decision

  1. A push to main starts GitHub Actions. It holds a private key whose public half sits in the server's authorized_keys with command="deploy-app <app> <host>" and no port forwarding, agent forwarding or terminal. Whatever the client asks for, that single command is all that runs.
  2. deploy-app takes a per-app lock, fetches main using a separate read-only GitHub deploy key, runs git reset --hard origin/main (Git wins, always), rebuilds with Compose, and then polls the app over HTTPS.
  3. If the app isn't returning HTTP 200 within 60 seconds, the job fails and the run turns red.
  4. Onboarding is one command, setup-new-app <app> <host>. It calls a root helper that validates the app name, refuses protected apps and hostnames already in use, creates both keys and logs the action to syslog.

Consequences

Revisit when

At bank scale

Build once in CI, sign the image (Sigstore/cosign), scan it, and promote the same digest through dev, test and prod. Argo CD pulls from Git, so CI never holds production credentials. Use OIDC federation instead of long-lived keys, and keep change records linked to commits for audit. The forced-command idea carries over directly: every automated identity gets exactly one capability.