CI/CD Best Practices Cheat Sheet

Last Updated: November 21, 2025

CI/CD Principles

Automate everything
Build, test, and deploy automatically
Commit frequently
Small, incremental changes
Fast feedback
Quick builds and tests
Test in production-like environments
Staging matches production
Rollback capability
Easy to revert changes
Monitor and alert
Track deployments and errors

GitHub Actions Example

# .github/workflows/ci.yml
name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup Node.js
      uses: actions/setup-node@v2
      with:
        node-version: '18'

    - name: Install dependencies
      run: npm ci

    - name: Run tests
      run: npm test

    - name: Build
      run: npm run build

    - name: Deploy
      if: github.ref == 'refs/heads/main'
      run: npm run deploy

Pipeline Stages

Stage Purpose
Source Trigger on code change
Build Compile and package code
Test Run automated tests
Security Scan Check for vulnerabilities
Deploy to Staging Test in staging environment
Deploy to Production Release to users
Monitor Track performance and errors
💡 Pro Tip: Start with simple pipelines and gradually add complexity!
← Back to DevOps & Cloud | Browse all categories | View all cheat sheets