On every push, the pipeline runs these stages:
- Install dependencies.
- Lint and type-check the code.
- Run unit tests.
- Build the artifact once. This is usually a Docker image tagged with the commit SHA.
- Run integration tests against real dependencies, such as a database container.
- Run security scans on the dependencies and the image.
- Deploy that same image to staging, and run smoke tests or end-to-end tests.
- Promote the image to production with a rolling, blue-green or canary strategy.
- Run post-deploy checks, and roll back automatically if they fail.
Why build once? You promote the same image through every environment. So production runs exactly what you tested. Only the configuration changes between environments.
Continuous delivery keeps every change ready to release. A human decides when to deploy to production. Continuous deployment goes one step further. Every change that passes the pipeline goes to production automatically.
- Run lint, type-check and unit tests early, because they are fast.
- Build the image once and tag it with the commit SHA.
- Run integration tests and security scans on the built image.
- Promote the same artifact from staging to production.
- Continuous delivery needs a manual release step. Continuous deployment releases automatically.