Day 89

CI/CD Pipeline

12 min
JavaScript 100 Days

CI/CD (Continuous Integration/Continuous Deployment) har code push par automatically tests run karta hai aur deploy karta hai. Manual deployment se chhutakara paao!

GitHub Actions Workflow

Automated CI/CD pipeline.

.github/workflows/deploy.yml
yaml
name: CI/CD Pipeline

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

jobs:
  test:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: "npm"
      
      - name: Install dependencies
        run: npm ci
      
      - name: Run linter
        run: npm run lint
      
      - name: Run tests
        run: npm test
        env:
          NODE_ENV: test
          JWT_SECRET: test-secret
      
      - name: Build check
        run: npm run build
  
  deploy:
    needs: test
    runs-on: ubuntu-latest
    if: github.ref == "refs/heads/main"
    
    steps:
      - name: Deploy to production
        run: |
          echo "Deploying to Render/Railway/Vercel..."
          # curl deployment webhook

🎯 Practice Challenge

GitHub repo mein CI/CD pipeline add karo — tests run karo, lint check karo, aur Render ya Railway par auto-deploy karo.