Skip to content

CI/CD Basics

What CI/CD Means

  • CI validates code automatically through build, lint, tests, and security scans.
  • CD delivers changes to staging or production through a predictable pipeline.

Typical Pipeline

  1. Checkout the code
  2. Install dependencies
  3. Lint and format checks
  4. Unit tests
  5. Build artifact or image
  6. Security scanning
  7. Push the artifact to a registry
  8. Deploy to an environment

What Matters in Infrastructure Pipelines

  • separate environments: dev, stage, prod
  • secrets management
  • rollback strategy
  • artifact immutability
  • audit trail

Common Tools

Minimal GitHub Actions Example

name: ci

on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm ci
      - run: npm test

Minimal Deployment Approach

  • build once
  • promote the same artifact between environments
  • do not rebuild a separate artifact just for prod

Practice

  • Secrets should not live in the repository.
  • A production deployment without tests, review, and a rollback plan is usually a bad idea.
  • For infrastructure changes, requiring plan or dry-run as a mandatory stage is a good default.