Site Tools


swe:ci-cd

Table of Contents

CI/CD

CI/CD is the practice of automatically building, testing, and deploying software on every change. Continuous integration runs the test suite on each commit; continuous delivery extends this by automatically packaging and deploying the artifact to production.

Without automation, integration happens in batches. Changes accumulate on parallel branches for weeks, then someone manually merges everything and discovers conflicts. Testing is deferred until a manual release cycle, so bugs are discovered late, by which point other changes have stacked on top and the regression is hard to isolate.

CI runs each commit through a pipeline: lint, build, test, package, deploy to staging, deploy to production. Each stage gates the next, so problems are caught at the cheapest point. A syntax error is found in seconds, not weeks later. Deployment becomes routine rather than an event, reducing anxiety and allowing rapid rollback if needed.

This GitHub Actions example shows the pipeline stages: lint and test block the build, and deployment only runs on main after all checks pass.

# GitHub Actions CI/CD example
name: CI/CD
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: npm install
      - run: npm run lint
      - run: npm test
      - run: npm run build
      - uses: actions/upload-artifact@v3
        with:
          name: dist
          path: dist/
  deploy:
    needs: build
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v3
        with:
          name: dist
      - run: ./deploy.sh
swe/ci-cd.md · Last modified: by 127.0.0.1