Stage 01
4 min read
Lesson 2 of 2

What is CI/CD?

Learn how Continuous Integration and Continuous Delivery automate software testing, packaging, and deployments to production environments.

Stage progress100% complete

What is CI/CD?

CI/CD stands for the combined practices of Continuous Integration (CI) and Continuous Delivery / Continuous Deployment (CD).

It represents the automated pipeline through which source code changes travel from a developer's local laptop all the way into live production environments with zero manual intervention.


Why does this matter?

Without CI/CD, releasing software is a manual, high-stress event:

  • Developers work on isolated code branches for weeks, leading to brutal "merge hell" conflicts when trying to combine changes.
  • Manual testing takes days and frequently misses regressions.
  • Server deployments involve SSH-ing into live production servers and manually running scripts at 2 AM.

CI/CD replaces manual risk with automated, repeatable pipelines that trigger instantly on every Git push.


1. Continuous Integration (CI)

In Continuous Integration, developers merge their code into the shared main branch frequently (often multiple times per day).

Every merge triggers an automated build and test pipeline:

git push ──► [ Automated Build ] ──► [ Linting & Static Analysis ] ──► [ Unit & Integration Tests ] ──► [ Docker Container Build ]

The Rules of Good CI:

  1. Maintain a Single Source Repository: All application code, configuration, and infrastructure templates live in Git.
  2. Automate the Build: Compiling and packaging happens automatically without manual flags.
  3. Make the Build Self-Testing: If any test fails, the build fails immediately, blocking the merge and notifying the engineer.
  4. Fast Execution: CI pipelines should ideally complete within 5 to 10 minutes to maintain developer momentum.

2. Continuous Delivery vs Continuous Deployment (CD)

While CI focuses on code validation, CD focuses on release automation:

Continuous Delivery:
Code Push ──► CI Tests Pass ──► Staging Deploy ──► [ Manual Approval Click ] ──► Production Deploy

Continuous Deployment:
Code Push ──► CI Tests Pass ──► Staging Deploy ──► [ Fully Automated ] ───────► Production Deploy
  • Continuous Delivery: Every successful build produces a release-ready artifact (e.g., Docker container, Helm chart). Deploying to production is a 1-click business decision.
  • Continuous Deployment: Every change that passes automated tests is deployed straight to production automatically with zero human intervention.

The Anatomy of a Modern CI/CD Pipeline

Consider a standard GitHub Actions workflow for a modern cloud application:

name: Production Deployment Pipeline

on:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Unit Tests
        run: npm run test

  build-and-push:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - name: Build Docker Image
        run: docker build -t myapp:${{ github.sha }} .
      - name: Push to Container Registry
        run: docker push registry.digitalocean.com/myapp:${{ github.sha }}

  deploy:
    needs: build-and-push
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to Kubernetes Cluster
        run: kubectl set image deployment/myapp myapp=myapp:${{ github.sha }}

Common Misconceptions

  • Misconception: CI/CD is only for large enterprises. Reality: Even solo developers and small teams save dozens of debugging hours per week by using automated GitHub Actions to catch errors before code reaches users.
  • Misconception: Continuous deployment is dangerous. Reality: Deploying small, incremental 20-line changes 10 times a day is far safer than deploying a massive 10,000-line change once a month.

Key Takeaways

[!IMPORTANT]

  • Continuous Integration (CI) automatically builds, lints, and tests code on every Git push.
  • Continuous Delivery (CD) ensures every change is ready to deploy to production at any time.
  • Automated pipelines eliminate manual server manipulation and accelerate software release cycles.

What comes next?

Congratulations on completing DevOps Basics!

In future stages, we will explore Containerization with Docker, Kubernetes Orchestration, and Infrastructure as Code (IaC) with Terraform.