Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

Best practices · Cloud and DevOps

CI/CD Best Practices

Opens with credits

A practical guide to CI/CD best practices for teams that ship code through a pipeline. It covers integrating small changes often, keeping the build fast and green, securing workflows and their credentials, building artifacts once with provenance, deploying gradually with canaries and fast rollback, and measuring delivery with the DORA metrics.

Written by Tauseef Fayyaz6 chapters, 25 practicesAbout 20 min20 quiz questionsReviewed 13 October 2026

What you will learn

6 chapters · about 20 min

  1. 1Integrating small changes oftenHow code should flow into main so that integration is continuous in practice, not just in name: trunk-based development, small batches and a main branch that is always releasable.4 practices · 3 min
  2. 2Fast feedback and tests you can trustA pipeline people trust is one that answers quickly and honestly. These practices keep builds fast and failures meaningful.4 practices · 3 min
  3. Securing the pipelineA CI system runs code with credentials to your cloud and your registry. These practices, from the GitHub Actions security guidance, keep it from becoming the easiest way in.5 practices · 4 minOpens with credits
  4. Artifacts and supply chainWhat the pipeline produces and how anyone can tell where it came from: build once, version immutably, record provenance and scan before release.4 practices · 3 minOpens with credits
  5. Deploying and releasing safelyHow to make deployment routine: fully automated, gradual, separated from feature release and quick to undo.5 practices · 4 minOpens with credits
  6. Measuring delivery with DORA metricsHow to tell whether the pipeline is getting better: the five DORA software delivery metrics and how to use them without gaming them.3 practices · 3 minOpens with credits

About this guide

CI/CD best practices come down to one promise: any commit on main can go to production safely, and quickly enough that nobody is tempted to work around the pipeline. Continuous integration keeps that promise on the code side, by merging small changes often and testing every one. Continuous delivery keeps it on the release side, by making deployment an automated, repeatable, boring event rather than a ceremony.

Most pipelines drift away from that over time. Builds slow down until people batch changes to avoid waiting. Flaky tests teach everyone to click re-run. Workflows collect long-lived cloud keys and third-party actions referenced by tags that anyone with access to that repository can move. Each artifact is rebuilt per environment, so what reached production is not quite what was tested. And releases go to everyone at once, so a bad change is a full outage instead of a small canary.

This guide follows the path of a change. The first chapters cover the integration side (trunk-based development, fast feedback and tests you can trust). The middle chapters cover the pipeline as an attack surface, using the GitHub Actions security guidance as the concrete example, and the build artifacts themselves, using SLSA provenance. The last chapters cover deploying gradually, rolling back fast and measuring how well it all works with DORA's software delivery metrics.

Every practice was checked against primary sources: DORA's research and capability guides, the GitHub Actions security documentation, the SLSA 1.2 specification and the Google SRE workbook. The examples use GitHub Actions because it is widely used, but each practice applies to GitLab CI, Jenkins, Buildkite or any other system.

Common questions

What are the DORA metrics?

DORA now uses five software delivery metrics. Throughput: change lead time, deployment frequency and failed deployment recovery time. Instability: change fail rate and deployment rework rate. They replaced the original four keys, and DORA recommends using them per service to improve over time, not as targets.

What is the difference between continuous delivery and continuous deployment?

Continuous delivery means any change on main can be released to production on demand, quickly and safely. Continuous deployment goes one step further and releases every change automatically. You can practise continuous delivery without adopting continuous deployment.

Should I pin GitHub Actions to a SHA or a tag?

GitHub recommends pinning to a full commit SHA, because tags can be moved or deleted if the action’s repository is compromised. Where your repository can use GitHub’s workflow dependency lockfile, GitHub describes it as the strongest protection and says it supersedes SHA pinning.

How long should a CI pipeline take?

DORA’s trunk-based development guidance says the build and test process should run in a few minutes. Run cheap checks first, cache dependencies, parallelise jobs and move slow end-to-end suites off the critical path.

What is SLSA?

SLSA (Supply-chain Levels for Software Artifacts) is a specification for build integrity, currently version 1.2. Its Build track levels go from L1 (provenance exists) through L2 (signed by a hosted platform) to L3 (a hardened platform with isolated runs and a protected signing key).

What is a canary deployment?

A canary sends a new version to a small part of production for a limited time and compares it with the rest of the service on the same metrics. If the canary is clearly worse, you stop and roll back before most users are affected.

Sources (8)

Checked against these, last on 13 October 2026.

  1. DORA’s software delivery performance metrics, DORAdora.dev/guides/dora-metrics/
  2. Capabilities: Trunk-based development, DORAdora.dev/capabilities/trunk-based-development/
  3. Capabilities: Deployment automation, DORAdora.dev/capabilities/deployment-automation/
  4. Secure use reference, GitHub Docsdocs.github.com/en/actions/reference/security/secure-use
  5. Capabilities: Continuous delivery, DORAdora.dev/capabilities/continuous-delivery/
  6. Managing environments for deployment, GitHub Docsdocs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments
  7. SLSA specification v1.2: Build track basics, OpenSSF SLSAslsa.dev/spec/v1.2/build-track-basics
  8. Canarying Releases, Google SRE Workbooksre.google/workbook/canarying-releases/

Picked from the other libraries by shared topics.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

  • 1:1 Mentorship
  • Fresh Graduate Mentorship
  • Career Guidance

Brand deals, promos and partnerships: tauseeffayyaz@gmail.com