CI/CD Best Practices

Chapter 1 · Practice 4 of 4

Define the pipeline as code next to the application

From Integrating small changes often

Why it matters

A pipeline configured by clicking in a web UI cannot be reviewed, versioned or restored. Keep workflow files in the repository, where changes go through the same review as the code.

DORA's deployment automation guidance adds that deployment scripts and configuration belong in version control too, so you can recreate any environment from it.

What lives in the repo:

  • build, test and deploy workflows
  • deployment scripts and environment configuration (without secrets)
  • the versions of tools the pipeline uses

Workflow files are code that runs with credentials, so give them owners. A CODEOWNERS entry for .github/workflows/ means changes to the pipeline are reviewed by someone who understands it.

Example

Code
# .github/CODEOWNERS
/.github/workflows/  @acme/platform
/deploy/             @acme/platform