Continuous Integration and Delivery
Automate builds, tests and deployments so every change to main is verified and shippable.
Intermediate · about 6 hours · difficulty 3/5
Learn first: Collaborating on Hosted Repositories, Integration and End-to-End Testing
Continuous Integration (CI) means every push and pull request is automatically built and tested, so problems surface within minutes. Continuous Delivery (CD) extends this so every change that passes is ready to deploy with one click; Continuous Deployment ships it automatically.
A typical backend pipeline
- Install dependencies (with caching).
- Lint and type-check.
- Run unit and integration tests (spinning up Postgres or Redis as service containers).
- Build an artifact, usually a Docker image, tagged with the commit SHA.
- Push the image to a registry.
- Deploy to staging, run smoke tests, then promote to production.
- Run database migrations as a controlled step.
Tools
GitHub Actions is the most common starting point; GitLab CI, CircleCI, Jenkins, Buildkite and cloud-native options are all widespread. Concepts transfer: workflows, jobs, steps, runners, secrets and artifacts.
Deployment strategies
- Rolling: replace instances gradually.
- Blue-green: run the new version alongside the old and switch traffic at once.
- Canary: send a small percentage of traffic to the new version and watch metrics.
- Feature flags decouple deploying code from releasing features.
Pitfalls
- Slow pipelines that people learn to ignore. Keep CI under about ten minutes.
- Secrets printed in logs. Use the platform's secret store and masking.
- No rollback plan.
You are ready to move on when a merge to main in your project automatically tests, builds an image and deploys it, and you have rolled back a bad deploy at least once.
Key concepts
- GitHub Actions
- GitLab CI, Jenkins, CircleCI
- Pipeline stages and caching
- Service containers for tests
- Artifacts and image registries
- Rolling, blue-green and canary
- Feature flags
- Rollbacks
Mini project
Create a GitHub Actions workflow that runs lint, tests against a Postgres service container, builds and pushes a Docker image, and deploys to your PaaS on merge to main.
Check yourself
What is the difference between continuous delivery and continuous deployment, and why might a team choose one over the other?
Free resources
- GitHub Actions documentation (GitHub)
- GitLab CI/CD (GitLab)
- Continuous Integration (Martin Fowler)