Skip to the page

CI/CD for developers · mid

Designing a pipeline for a new service

A good pipeline gives fast feedback on every pull request, builds one artifact on main, and promotes the same artifact through staging to production with approval and a way back.

The notes

What you must know

  • Pull request: lint, unit tests, build, integration tests against real dependencies (Testcontainers or compose), dependency and secret scanning, static analysis, and building and scanning the image. Aim for feedback in about 10 minutes.
  • Main branch: build once, tag the image with the commit SHA (immutable tags in ECR), push it, sign it, and attach an SBOM and provenance.
  • Deploy to staging automatically (Helm, or GitOps where the pipeline changes the image tag in an environment repository and Argo CD or Flux applies it), then run smoke tests.
  • Production: the same digest, after an approval (GitHub environments with required reviewers, or a manual job). A rolling, canary or blue-green strategy with automatic checks and rollback.
  • Secrets: use short-lived cloud credentials through OIDC from the CI system to the cloud, not stored long-lived keys.
  • Fail fast: put the cheapest checks first and run independent jobs in parallel.
  • Make deploys visible: record which version runs where, post to chat, and mark deploys on dashboards.

The red pen

Common traps: mistake → fix

  • Mistake: Rebuild the image for each environment

    Fix: Build once and promote the same digest.

  • Mistake: Stored cloud keys in CI are fine

    Fix: They leak and live long. Use OIDC and short-lived roles.

  • Mistake: More checks in the pull request is always better

    Fix: Slow pipelines get ignored. Keep it fast and move slow checks to main or nightly.

Easy to hard

Questions interviewers ask, easy to hard

  1. Describe the stages of a CI/CD pipeline for a new microservice.
  2. Why build the image once and promote it?
  3. How should the pipeline authenticate to AWS?
  4. What goes in the pull request pipeline and what goes in the main branch pipeline?
  5. Design the whole pipeline from a pull request to production for a payments API.

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview