All guides

What a CI/CD pipeline should do on every commit

A pipeline is the one road from a commit to production. When it does these seven things every time, a release stops being an event.

A laptop showing a stylesheet in a code editor

1. Build once and keep the artifact

Build one image or package per commit, tag it with the commit hash, and move that same artifact through test, staging and production. If each environment builds its own, you test one thing and ship another.

2. Run the fast tests first

Linting and unit tests should answer within a few minutes. Put the slow suites after them, so a typo fails in two minutes and not in twenty.

3. Scan what you ship

Check dependencies and the built image for known vulnerabilities on every run. Fail the build on the serious ones, and give every exception an expiry date so the list does not grow forever.

4. Keep long-lived keys out of the pipeline

A cloud key stored as a pipeline variable is a key that never rotates. Most CI systems can swap a signed identity token for short-lived cloud credentials instead. In GitHub Actions on AWS it looks like this:

permissions:
  id-token: write
  contents: read

steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/deploy
      aws-region: eu-west-1

5. Deploy every environment the same way

One deploy job, with the environment as a parameter. Production gets an approval step, not a different script. The first time a script runs should never be the production release.

6. Make rollback one step

Rolling back means deploying the previous artifact again, which you still have because of step one. Try it on a quiet day. A rollback nobody has run is a plan, not a feature.

7. Say what happened

Post each result where the team already talks, with the commit, its author and a link to the run. Then keep two numbers: how long a commit takes to reach production, and how often a release has to be undone.

Where to start

Read your own pipeline against this list. The first step it skips is usually the one that hurt you last quarter.

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides