Skip to content
Blog

Engineering

CI/CD pipeline setup: from commit to production without dread

The stages, checks, and rollback strategy behind a CI/CD pipeline that lets small teams deploy daily with confidence. No babysitting required.

By Pykero Agency · Engineering teamJul 8, 20265 min read

TL;DR

A well-structured CI/CD pipeline turns deployment from a manual ritual into a background event. Build once, promote the same artifact, and make rollback a first-class operation.

Automated pipeline conveyor moving code artifacts to production

The gap between a team that ships daily and one that dreads every release usually isn't talent. It's the pipeline. A well-built CI/CD pipeline setup turns deployment into a background event that happens quietly, dozens of times a day, without anyone holding their breath.

Continuous integration: fail loudly, fail early

CI runs on every push and pull request. Its job is to catch problems before they reach anyone else. Run these stages in order, fastest first:

  1. Lint and format checks. Instant feedback. No reason to wait on these.
  2. Type checks. With TypeScript, a failing type check catches an entire class of bug before a single test executes.
  3. Unit and integration tests. The core safety net. Keep them fast so nobody routes around them.
  4. Build. Prove the app actually compiles into a deployable artifact.

Order matters more than most teams realize. If a lint failure has to wait ten minutes behind the full test suite, people stop fixing lint. Keep the total run under ten minutes. Past that threshold, developers start merging anyway and checking back later, which defeats the point.

Build once, promote the same artifact

One of the most common CI/CD mistakes is rebuilding the application separately for staging and production. Build a single artifact instead. A Docker image works well for this: tag it with the commit SHA, push it once, and promote that exact image through every environment. If it passed tests in staging, the identical bytes go to production. The "it worked in staging" class of bug disappears almost completely.

This also makes rollbacks faster and more predictable, because you're always reverting to an image you've already run, not rebuilding something from a previous commit.

Continuous delivery: automate the routine, gate what matters

Merging to main should trigger an automatic deploy to staging for most teams. Production can be one approved step behind that, or fully automated once you trust your test coverage. The principle is that deployment is a script, not a runbook someone follows by hand at 11pm.

Use a safe rollout strategy so one bad release doesn't take everything down at once:

  • Blue-green deployments keep the previous version warm. If something goes wrong, traffic switches back in seconds.
  • Canary releases send a small slice of real traffic to the new version first, let you watch error rates and latency, and only proceed if the metrics hold.

Which one to use depends on your infrastructure and risk tolerance. Canary gives you more signal before full rollout; blue-green is simpler to operate. Both are better than deploying to 100% of users at once and hoping.

Rollback as a first-class operation

Everything breaks eventually. What separates calm teams from panicking ones is how fast they recover. Rollback should be a single, well-tested command that reverts to the last known-good version in under a minute. If reverting is scary or manual or slow, you'll hesitate at exactly the moment speed matters most.

Rehearse it. Run a rollback drill on a Tuesday afternoon, not during an incident. Teams that have never practiced rollback discover the hard way that the command is broken, or that nobody knows where it lives, or that it works for app code but not for database migrations. Treat it like a fire drill.

On database migrations specifically: prefer additive, backward-compatible changes whenever possible. A new column the old code ignores is safe to deploy ahead of the app. Dropping a column the old code still reads is not. This constraint shapes how you structure the migration, not how you structure the deployment.

Protect the pipeline itself

Two rules prevent most self-inflicted outages. First, never bake secrets into images or let them surface in build logs. Inject them at runtime from a secrets manager. Second, protect your main branch: require passing CI checks and at least one review before merge. The pipeline is the only path to production, and nobody gets to push around it.

Combined, these rules mean the pipeline is authoritative. If it passes, you ship. If it fails, nothing moves. That clarity is what makes daily deploys feel boring rather than brave.

Start with the minimum that actually helps

You don't need everything on day one. Start with automated tests on every pull request and a one-command deploy script. Add canary rollouts and production monitoring as the stakes increase. Even a thin pipeline, tests plus automated deploy, changes how a team works, because "did I break something?" stops being a fear and becomes a fact the machine answers for you.

If your releases still involve manual steps and held breath, let's talk.

ci/cd pipeline setupcontinuous integration continuous deploymentautomate deploymentsdocker ci/cd pipelinerollback strategy deploymentautomated testing pipeline

Frequently asked questions

how long should a ci/cd pipeline take to run

Under ten minutes for the full run. Longer than that and developers start skipping it or context-switching away. Run the cheapest checks first so a lint failure surfaces in seconds, not after the full test suite.

should i rebuild the app for each environment

No. Build one artifact, ideally a Docker image, and promote the exact same image from staging to production. Separate builds mean separate failure modes, and that's where 'it worked in staging' bugs come from.

when should production deployment be fully automated

Once your test coverage is meaningful and you have canary releases or blue-green deployments in place. Until then, auto-deploy to staging and keep production one manual approval behind it.

how do i protect secrets in a ci/cd pipeline

Never bake secrets into images or let them appear in build logs. Inject them at runtime from a secrets manager like AWS Secrets Manager, HashiCorp Vault, or your platform's equivalent. This also applies to API keys used during the build itself.

How Pykero can help

Services related to this article.

Building something like this?

Pykero Agency designs and ships production web, mobile, SaaS, and AI products.

Talk to us

Discussion

Be the first to comment.

Related reading