Skip to content

13. Deploy Should Mean pull, Not git clone

Lesson 12 treated the cloud VM like a second developer machine: clone the repo, docker compose build, run. That ties production to whatever commit happened to be checked out, and burns a 1GB VM’s limited memory rebuilding on every change. This lesson separates the two roles cleanly: GitHub Actions owns build truth (Lesson 6 already produces signed, SHA-tagged images in GHCR), the VM owns runtime state, and a release becomes docker pull plus docker compose up --no-deps — never git clone, never a build, on the server. The VM keeps a directory with a production Compose file and a .env for secrets, and nothing else from the application source tree.

Getting there took seven distinct, unrelated bugs

Section titled “Getting there took seven distinct, unrelated bugs”

Not one tricky problem — seven small ones, each in a completely different category, each blocking the pipeline until fixed:

YAML structure. script: has to live inside the SSH action’s with: block, as one of its inputs — not as a sibling key at the step level. Easy to get wrong, and the parse error doesn’t point at the actual fix.

A Postgres version change nobody flagged. Postgres 18’s official image expects its volume mounted at /var/lib/postgresql, not /var/lib/postgresql/data — the path used in most existing examples, including the lesson’s own text, which predates this change. The old path makes the container think it’s looking at a stale, foreign data directory and refuse to start.

Actions that don’t accept the input tutorials assume they do. Both appleboy/scp-action and appleboy/ssh-action are widely used for exactly this copy-then-run pattern — and neither actually accepts known_hosts as a valid input in the versions used here, despite it appearing in most tutorials for both. Including it produces a silent warning, not an error, so it’s easy to believe host-key verification is happening when it isn’t.

A cloud firewall rule that was correct for a human, wrong for a robot. SSH had been locked to one specific home IP — sensible for personal access, useless for GitHub Actions, which connects from its own large, constantly rotating IP ranges rather than any single fixed address. Every deploy attempt failed with a silent connection timeout until that rule opened up.

Two SSH keypairs, easy to conflate. One keypair existed specifically for cloning the private repo onto the VM — registered only with GitHub, never trusted by the VM itself. A separate keypair was the VM’s actual access credential, the one already in ~/.ssh/authorized_keys. The wrong one went into the deploy secret first; the fix was confirming which key the VM itself actually trusted, not regenerating anything.

An action’s target path meaning something different than expected. scp-action’s target parameter wants a directory — it appends the source filename itself. Passing a full destination file path instead makes it try to create a folder with that name, which fails outright.

A tag format mismatch between build and deploy. The build job’s own metadata step tags images with a short, 7-character SHA — that’s genuinely what gets published to GHCR. The deploy job’s IMAGE_TAG was set to github.sha, the full 40-character hash. Two different tag formats for the identical commit, so the deploy step was always going to fail to resolve a reference that was never actually published.

Why the verification step matters more than “the pipeline ran”

Section titled “Why the verification step matters more than “the pipeline ran””

A green Actions run isn’t the actual proof. The real check: after a deploy, backend and frontend show a fresh uptime timestamp — just restarted — while postgres and redis show whatever uptime they already had, completely unchanged. That’s the entire point of --no-deps scoped to exactly two services: a routine app release shouldn’t touch the data tier at all, and confirming that with real uptime numbers is a stronger check than “the workflow succeeded.”

Teams in the 10-150 person range run exactly this pattern for internal tools before reaching for Kubernetes: one VM, Compose, a registry, Actions over SSH. What breaks teams isn’t the pattern — it’s coupling: one Compose file covering both app and observability, or a deploy script that runs down before up “to be clean,” which guarantees brief outages and occasionally deletes volumes the moment someone copies a tutorial flag with -v in it. docker compose down -v never belongs in an automated deploy script — that’s the one line worth banning outright, not just discouraging.


Next: bringing DevOps Foundation and Automation & Operations together — the portfolio’s cloud-hosted core is now live, automated, and observable.