Overview
Curated: · Written: · Reviewed:
CI/CD Pipeline Design
In one line
CI/CD automates the path from a commit to a tested, digest-identified artifact and, where policy allows, its release. Reach for it when every change must be integrated and tested the same way, and every production release must trace back to one immutable artifact.
Key definitions
- Digest: the sha256 of the image manifest. It is the artifact's identity. Tags are mutable pointers to it.
- Build once, promote: one build per commit. The same digest moves through staging and production, and environment config is injected at deploy time.
- Continuous delivery: every passing change yields a deployable artifact. A person decides when to release.
- Continuous deployment: passing changes release automatically. The pipeline's evidence is the release authority.
- Expand/migrate/contract: the three-step schema change that keeps old and new code compatible during a rollout.
- Chain of custody: the recorded link from source revision to digest to signed provenance to running pods.
How it works
A pull request builds against the merge ref, the PR merged into the current base, so a green PR can still break main once a second PR lands. Stages form a DAG through needs:, so fast checks fail first. The build pushes an image and emits its digest. Attestation binds that digest to the commit and build inputs. Deploy pulls by digest, never by tag. Readiness gates traffic, and smoke tests plus SLO checks verify from the user boundary.
When to use and when not to
| Situation | Choice | Why |
|---|---|---|
| Shared service, several deploys a day | Full pipeline: DAG, digest promotion, progressive rollout | Integration risk stays small and rollback has evidence behind it |
| One deploy a week, no real test suite | Build script that records the digest, manual deploy | Stages you do not run add ceremony without signal |
| Regulation requires human sign-off | Continuous delivery with a gated, auditable release | Continuous deployment is off the table by policy |
| No detection in production yet | Fix observability first | Automation without detection only widens blast radius |
| Monorepo at thousands of PRs a day | Selective testing, remote cache, merge queue | Running everything per PR stops fitting in a merge gate |
Traps interviewers probe
- Rebuilding per environment. Staging and production then run different bytes for the same commit. Fix: build once, promote the digest, inject config at deploy time.
- Deploying a tag.
:stablecan be overwritten, so the release record names a tag that no longer means what it did. Fix: reference the digest in manifests, and make the registry reject tag overwrites. - Interpolating untrusted context into
run:. A PR title inecho "${{ github.event.pull_request.title }}"executes as shell. Fix: pass the value through anenv:variable and quote it, or validate it first. - Trusting a SHA pin to cover runtime downloads. Pinning an action fixes its code, not a
curl | tarthat fetches a moving URL during the run. Fix: vendor the payload or verify its checksum. - Treating masking as containment. Masked logs still leak through artifacts, caches, network egress and written files. Fix: give untrusted code no secrets and no shared writable cache.
Interview tips
Open with the invariant: one revision, one immutable artifact, promoted by digest, verified at the boundary. Then name the stage that enforces it.
Expect these follow-ups:
- Delivery versus deployment? Who holds the release authority, and how that raises the bar on flaky-test rate.
- Why deploy by digest? Tags are names. Digests are content identity. A signature proves who built it, not that it is correct.
- A flaky test blocks a Friday release. Quarantine it with an owner and a deadline, ship, then fix the race.
- A release is erroring: first move? Check whether a flag disable or traffic shift is faster. Rollback re-enters the deploy path.
- You rolled back and lost data. Application rollback cannot undo a destructive migration. Expand/migrate/contract prevents this.
- What can a fork PR poison? Shared caches, workspaces on persistent runners, and any artifact a privileged job later reads.
30-second outline: "Each commit builds one digest-addressed artifact. Gates attach evidence to it: fast checks on the PR, integration on the merge, attestation at packaging. Staging and production deploy that same digest with environment config injected at deploy time. Releases are gated by policy, and rollback is a traffic or flag move first. Schema changes use expand/migrate/contract so rollback stays safe."
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.