Learn 🧠 All Concepts (20) 🤖 What is an LLM? 📚 RAG Explained ⚡ AI Agents 💻 Run AI Locally 🇮🇳 AI in India 📖 Learn Tracks 🔧 DevOps Track ⚙️ AI Ops Track 🗺️ AI Engineer Roadmap
Tools 🔧 AI Tools Directory 🔓 Open Source AI ⭐ Top GitHub Repos ✦ Claude Skill Repos 🚀 Ready-to-Deploy Projects
Build 🏗️ Build Hub 🎯 Master Prompts 🧩 RAG Agents 🚀 App Megaprompts
Workflows ⚡ All Workflows (22) 🎥 Text to Video 🎞️ Image to Video 🔊 Text to Speech ♻️ Automation
Resources 🧪 Colab Notebooks ⚙️ n8n Workflows 📈 Algo Trading 💰 Passive Income
🗂️ Browse All Topics About AItheGuru
Learn DevOps The robot that ships code
DevOps Ch 4 / 10 Intermediate
🤖

The robot that ships code

CI/CD pipelines — automatic testing, building, and deploying so you can sleep at night

⏱ 12 min 3 commands 4 takeaways
🤖
In this chapter
Arjun
Now leading the team at the startup
The story

Six months after joining, Arjun was leading deployments. Every Friday evening the team would push code, then someone would manually run tests, build the Docker image, SSH into the server, pull the latest code, restart the service, and pray.

It took two hours every time. Once, Vikram forgot to run tests. A bug went live at 6pm on a Friday. It took until Sunday to fix.

"There has to be a better way," Arjun told his manager.

"There is," she said. "It's called CI/CD."

What is CI/CD?

CI — Continuous Integration: Every time someone pushes code, an automated system immediately runs all the tests. If tests fail, the code doesn't proceed. This catches bugs before they reach production.

CD — Continuous Deployment: If tests pass, the code is automatically built, packaged, and deployed to the server. No manual steps. No forgotten tests. No Friday evening rituals.

Think of CI as the quality inspector on a factory line — every product gets checked before moving forward. CD is the conveyor belt that delivers the approved product to the customer automatically.

GitHub Actions — the most popular CI/CD tool

GitHub Actions runs workflows defined in YAML files inside your repository. Every push to the main branch triggers the workflow.

```yaml

.github/workflows/deploy.yml

name: Test and Deploy

on:

push:

branches: [main]

jobs:

test:

runs-on: ubuntu-latest
steps:
  - name: Get the code
    uses: actions/checkout@v3
  - name: Setup Python
    uses: actions/setup-python@v4
    with:
      python-version: '3.11'
  - name: Install dependencies
    run: pip install -r requirements.txt
  - name: Run tests
    run: pytest tests/

deploy:

needs: test  # Only runs if tests pass
runs-on: ubuntu-latest
steps:
  - name: Deploy to server
    run: |
      ssh user@server "
        cd /app &&
        git pull &&
        docker compose up -d --build
      "

```

What happens every time someone pushes code now:

1. GitHub Actions starts automatically — no human trigger needed

2. It installs all dependencies on a fresh virtual machine

3. It runs every single test

4. If any test fails — it stops and sends an email. Nothing gets deployed.

5. If all tests pass — it SSHes into the server and deploys automatically

6. The whole thing takes 4 minutes

Arjun's Friday evenings became free. The team deployed 3-4 times a day instead of once a week. Bugs got caught in minutes, not days.

The stages of a real pipeline

```

Push code → Lint (code style check) → Unit tests →

Integration tests → Build Docker image →

Push to registry → Deploy to staging →

Run smoke tests → Deploy to production

```

Not every team does all of these. But every team should at minimum: run tests and deploy automatically.

Arjun's rule for new teams: Start simple. One workflow. Three steps: checkout → test → deploy. Add complexity only when you feel pain.

Key takeaways

CI runs tests automatically on every code push — catches bugs early

CD automatically deploys code when tests pass — no manual work

GitHub Actions uses YAML files stored in your repository

Start simple: checkout → test → deploy. Add steps when needed

Commands from this chapter
$ git push origin main
Triggers your CI/CD pipeline automatically
$ gh run list
See recent GitHub Actions runs (GitHub CLI)
$ gh run watch
Watch a pipeline run in real-time