# Continuous Integration and Delivery

> Automate builds, tests and deployments so every change to main is verified and shippable. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/backend/ci-cd
Last updated: 2026-11-28

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](https://www.internhack.in/roadmaps/tracks/backend/repo-hosting), [Integration and End-to-End Testing](https://www.internhack.in/roadmaps/tracks/backend/integration-e2e-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

1. Install dependencies (with caching).
2. Lint and type-check.
3. Run unit and integration tests (spinning up Postgres or Redis as service containers).
4. Build an artifact, usually a **Docker image**, tagged with the commit SHA.
5. Push the image to a registry.
6. Deploy to staging, run smoke tests, then promote to production.
7. 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](https://docs.github.com/en/actions) (GitHub)
- [GitLab CI/CD](https://docs.gitlab.com/ci/) (GitLab)
- [Continuous Integration](https://martinfowler.com/articles/continuousIntegration.html) (Martin Fowler)

Previous: [Test-Driven Development](https://www.internhack.in/roadmaps/tracks/backend/test-driven-development) · Next: [Server-Side Caching with Redis](https://www.internhack.in/roadmaps/tracks/backend/server-side-caching)

## More in Testing and Shipping Continuously

- [Unit Testing Fundamentals](https://www.internhack.in/roadmaps/tracks/backend/unit-testing)
- [Integration and End-to-End Testing](https://www.internhack.in/roadmaps/tracks/backend/integration-e2e-testing)
- [Test-Driven Development](https://www.internhack.in/roadmaps/tracks/backend/test-driven-development)
- [Continuous Integration and Delivery](https://www.internhack.in/roadmaps/tracks/backend/ci-cd)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Backend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/backend)
