Diseña e implementa el pipeline de CI/CD completo con GitHub Actions: tests automatizados, análisis de seguridad, build de artefactos y deploy progresivo a staging y producción con rollback automático.
Cuándo usarlo: DevOps, CI/CD, GitHub Actions, automatización de deployments
Herramienta recomendada: Claude
Eres un DevOps Engineer especializado en pipelines de CI/CD para equipos de 2-20 developers que quieren automatizar su flujo de deployment sin overhead de gestión. Mi stack: - Lenguaje / framework: [Node.js / Python / Go / PHP Laravel / Ruby on Rails / otro] - Containerización: [Docker / sin contenedores] - Infraestructura destino: [AWS / GCP / Azure / Hetzner / VPS / Kubernetes / otro] - Branches principales: [main / develop / feature branches] - Tests existentes: [unitarios / integración / e2e / ninguno todavía] - Problema principal del CI/CD actual: [no hay / muy lento / deployments manuales / sin tests / falta de staging] ## Pipeline CI/CD — [Proyecto] con GitHub Actions ### 🏗️ Arquitectura del pipeline ``` Push a branch → [CI] Lint + Tests + Security scan → [Build] Docker image + tag → [Deploy Staging] auto → smoke tests → [Deploy Prod] manual approval / auto en merge a main → [Notify] Slack / email ``` ### 📄 Workflow completo (.github/workflows/ci-cd.yml) ```yaml name: CI/CD Pipeline on: push: branches: [main, develop] pull_request: branches: [main] env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: # ── 1. CI: Lint + Tests ────────────────────────────────── test: name: Tests & Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup [Node/Python/Go/PHP] uses: actions/setup-[runtime]@v4 with: [version]: '[tu versión]' cache: '[tu package manager]' - name: Install dependencies run: [tu comando de install] - name: Run linter run: [tu comando de lint] - name: Run tests run: [tu comando de tests] env: [TUS_VARIABLES_DE_ENTORNO]: ${{ secrets.SECRET_NAME }} - name: Upload coverage uses: codecov/codecov-action@v4 # ── 2. Security scan ──────────────────────────────────── security: name: Security Scan runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: scan-type: 'fs' severity: 'HIGH,CRITICAL' exit-code: '1' # ── 3. Build Docker image ─────────────────────────────── build: name: Build & Push Image needs: [test, security] runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/build-push-action@v5 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max # ── 4. Deploy Staging ─────────────────────────────────── deploy-staging: name: Deploy to Staging needs: build runs-on: ubuntu-latest environment: staging if: github.ref == 'refs/heads/develop' steps: - name: Deploy to staging [tu paso de deploy específico según infraestructura] # ── 5. Deploy Production ──────────────────────────────── deploy-production: name: Deploy to Production needs: build runs-on: ubuntu-latest environment: production # requiere aprobación manual en GitHub if: github.ref == 'refs/heads/main' steps: - name: Deploy to production [tu paso de deploy con rollback automático] ``` ### 🔐 Secrets necesarios Lista de secrets a configurar en GitHub Settings → Secrets + cómo configurarlos. ### 🔄 Estrategia de rollback automático Si el smoke test de producción falla: cómo revertir al SHA anterior automáticamente. ### ⚡ Optimizaciones de velocidad del pipeline Cómo bajar de 10 min a <5 min con caché de dependencias y paralelización de jobs.