Best practices · Cloud and DevOps
CI/CD Best Practices
Opens with creditsA 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.
What you will learn
6 chapters · about 20 min
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
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
- 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
- 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
- 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
- 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.
- DORA’s software delivery performance metrics, DORAdora.dev/guides/dora-metrics/
- Capabilities: Trunk-based development, DORAdora.dev/capabilities/trunk-based-development/
- Capabilities: Deployment automation, DORAdora.dev/capabilities/deployment-automation/
- Secure use reference, GitHub Docsdocs.github.com/en/actions/reference/security/secure-use
- Capabilities: Continuous delivery, DORAdora.dev/capabilities/continuous-delivery/
- Managing environments for deployment, GitHub Docsdocs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments
- SLSA specification v1.2: Build track basics, OpenSSF SLSAslsa.dev/spec/v1.2/build-track-basics
- Canarying Releases, Google SRE Workbooksre.google/workbook/canarying-releases/
Related on Sefism
Picked from the other libraries by shared topics.
Roadmaps
See allCheat sheets
See allBest practices
See all- Docker Best PracticesWrite smaller, faster, safer Docker images: multi-stage Dockerfiles, layer caching, non-root users, build secrets, health checks and Compose.
- Kubernetes Best PracticesRun workloads on Kubernetes that schedule well, survive restarts and node drains, and stay locked down: resources, probes, PDBs, Pod Security and RBAC.
- Terraform Best PracticesWrite Terraform that teams can review and change safely: file layout, version pinning, remote state with locking, secrets, modules, refactoring and tests.
Checklists
See all- Incident Response ChecklistPrepare for and handle production incidents: on-call, severity levels, declaring, roles, mitigation, security containment, status updates and blameless postmortems.
- Production Readiness ChecklistCheck a service before it takes real traffic: ownership, SLOs, capacity, timeouts and retries, alerts, rollout and rollback, backups, security and on-call.
- Kubernetes Production ChecklistVerify a workload and its cluster before real traffic: requests and limits, probes, PDBs, spread, Pod Security, RBAC, network policies, secrets, images, autoscaling, upgrades and backups.
Project structures
See all- Terraform project structureAn infrastructure repository for a small app on AWS: reusable modules, one folder per environment with its own remote state, pinned providers, tests and security scans, with plan on every pull request and apply from CI. For students who have finished the Terraform tutorials and want to know how a real team lays out the files. The same layout works unchanged with OpenTofu.
- Kubernetes with Helm project structureA Helm chart repository for one app: the chart that
helm creategives you, grown into a tested, versioned package with per-environment values, unit tests, install tests in a kind cluster and releases to an OCI registry. For students who can write a Deployment by hand and want to know how a team organises charts. It is about the repo layout and what each file does, not about cluster design. - Spring Boot project structureA REST API in Java with Spring Boot 4, PostgreSQL, Flyway and Testcontainers, organised by feature the way the Spring docs suggest. It grows from the Initializr scaffold to a service with JWT security, problem-detail errors, MapStruct DTOs, slice and integration tests, CI, containers and observability, and finally Modulith boundaries, contract and load tests. For students who know some Java and want to see how a real service is organised.
Career questions
See all- Do I need Docker and Kubernetes as a junior developer?Docker, yes: learn the basics, because nearly every team uses containers and you will be expected to run the project locally and read a Dockerfile. Kubernetes, mostly no: understand what it does and a few core terms, but deep Kubernetes can wait until your job or a DevOps direction needs it.
- What is platform engineering, and how is it different from DevOps?DevOps is a culture and set of practices: developers and operations sharing responsibility for shipping and running software. Platform engineering is one way to put that into practice at scale: a team builds an internal platform, a paved road of tools and templates, so product teams can ship without becoming infrastructure experts.
- Can I become an SRE or platform engineer straight after graduating?Sometimes, but it is rare, because these roles expect you to have run production systems. The more reliable path is a first job in backend, DevOps or cloud support, where you learn production, then a move into SRE or platform work within a couple of years.
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