CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.
CI/CD Pipeline Generator
Command
/generate-pipeline
Overview
A Claude Code command that analyzes your project structure, detects your tech stack, and generates a complete CI/CD pipeline configuration. Supports GitHub Actions, GitLab CI, CircleCI, and Bitbucket Pipelines. Generates workflows for testing, building, security scanning, and deploying to various cloud providers.
Quick Start
# Auto-detect project and generate pipeline claude "Generate a CI/CD pipeline for this project" # Specify platform and deployment target claude "Create a GitHub Actions pipeline that deploys to AWS ECS" # Generate a specific workflow claude "Create a GitHub Actions workflow for running tests on pull requests"
Supported Platforms
| CI/CD Platform | Config File | Detection |
|---|---|---|
| GitHub Actions | .github/workflows/*.yml | .github/ directory |
| GitLab CI | .gitlab-ci.yml | .gitlab-ci.yml or GitLab remote |
| CircleCI | .circleci/config.yml | .circleci/ directory |
| Bitbucket Pipelines | bitbucket-pipelines.yml | bitbucket-pipelines.yml |
GitHub Actions Templates
Basic CI (Test + Lint + Build)
# .github/workflows/ci.yml name: CI on: push: branches: [main, develop] pull_request: branches: [main] concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: lint: name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' - run: npm ci - run: npm run lint - run: npm run type-check test: name: Test runs-on: ubuntu-latest needs: lint services: postgres: image: postgres:16 env: POSTGRES_USER: test POSTGRES_PASSWORD: test POSTGRES_DB: test_db ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 redis: image: redis:7 ports: - 6379:6379 env: DATABASE_URL: postgresql://test:test@localhost:5432/test_db REDIS_URL: redis://localhost:6379 NODE_ENV: test steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' - run: npm ci - run: npm run db:migrate - run: npm test -- --coverage - uses: actions/upload-artifact@v4 if: always() with: name: coverage path: coverage/ build: name: Build runs-on: ubuntu-latest needs: test steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' - run: npm ci - run: npm run build - uses: actions/upload-artifact@v4 with: name: build path: dist/
Full Pipeline (CI + CD with Staging + Production)
# .github/workflows/deploy.yml name: Deploy on: push: branches: [main] workflow_dispatch: inputs: environment: description: 'Deployment environment' required: true default: 'staging' type: choice options: - staging - production concurrency: group: deploy-${{ github.ref }} cancel-in-progress: false # Never cancel deployments jobs: test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' - run: npm ci - run: npm run lint - run: npm run type-check - run: npm test security: name: Security Scan runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm audit --audit-level=high - uses: github/codeql-action/init@v3 with: languages: javascript-typescript - uses: github/codeql-action/analyze@v3 build: name: Build & Push Docker Image runs-on: ubuntu-latest needs: [test, security] outputs: image_tag: ${{ steps.meta.outputs.tags }} steps: - uses: actions/checkout@v4 - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} tags: | type=sha,prefix= type=ref,event=branch - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max deploy-staging: name: Deploy to Staging runs-on: ubuntu-latest needs: build environment: name: staging url: https://staging.example.com steps: - uses: actions/checkout@v4 - name: Deploy to staging run: | echo "Deploying ${{ needs.build.outputs.image_tag }} to staging" # Your deployment command here - name: Run smoke tests run: | sleep 30 # Wait for deployment curl -sf https://staging.example.com/health || exit 1 deploy-production: name: Deploy to Production runs-on: ubuntu-latest needs: [build, deploy-staging] if: github.ref == 'refs/heads/main' environment: name: production url: https://example.com steps: - uses: actions/checkout@v4 - name: Deploy to production run: | echo "Deploying ${{ needs.build.outputs.image_tag }} to production" - name: Run smoke tests run: | sleep 30 curl -sf https://example.com/health || exit 1 - name: Notify Slack if: always() uses: 8398a7/action-slack@v3 with: status: ${{ job.status }} fields: repo,commit,author,action env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
Pull Request Checks
# .github/workflows/pr-checks.yml name: PR Checks on: pull_request: types: [opened, synchronize, reopened] jobs: changes: name: Detect Changes runs-on: ubuntu-latest outputs: backend: ${{ steps.filter.outputs.backend }} frontend: ${{ steps.filter.outputs.frontend }} docs: ${{ steps.filter.outputs.docs }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 id: filter with: filters: | backend: - 'backend/**' - 'package.json' frontend: - 'frontend/**' - 'package.json' docs: - 'docs/**' - '*.md' backend-tests: name: Backend Tests needs: changes if: needs.changes.outputs.backend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' - run: cd backend && npm ci && npm test frontend-tests: name: Frontend Tests needs: changes if: needs.changes.outputs.frontend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' - run: cd frontend && npm ci && npm test preview-deploy: name: Preview Deployment needs: [backend-tests, frontend-tests] if: always() && !failure() runs-on: ubuntu-latest environment: name: preview url: ${{ steps.deploy.outputs.url }} steps: - uses: actions/checkout@v4 - name: Deploy preview id: deploy run: | # Deploy to preview environment (Vercel, Netlify, etc.) echo "url=https://pr-${{ github.event.number }}.preview.example.com" >> $GITHUB_OUTPUT
Deployment Targets
AWS (ECS / Fargate)
deploy: steps: - uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 - uses: aws-actions/amazon-ecr-login@v2 - name: Build and push to ECR run: | docker build -t $ECR_REPO:$GITHUB_SHA . docker push $ECR_REPO:$GITHUB_SHA - name: Deploy to ECS run: | aws ecs update-service \ --cluster production \ --service my-app \ --force-new-deployment
Vercel (Frontend)
deploy: steps: - uses: amondnet/vercel-action@v25 with: vercel-token: ${{ secrets.VERCEL_TOKEN }} vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} vercel-args: '--prod'
Docker Compose (VPS)
deploy: steps: - name: Deploy via SSH uses: appleboy/ssh-action@v1 with: host: ${{ secrets.SERVER_HOST }} username: deploy key: ${{ secrets.SSH_PRIVATE_KEY }} script: | cd /app docker compose pull docker compose up -d --remove-orphans docker system prune -f
Kubernetes
deploy: steps: - uses: azure/k8s-set-context@v4 with: kubeconfig: ${{ secrets.KUBECONFIG }} - run: | kubectl set image deployment/my-app \ app=ghcr.io/${{ github.repository }}:${{ github.sha }} kubectl rollout status deployment/my-app --timeout=300s
Dockerfile Templates
Node.js (Multi-stage)
# Build stage FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci --production=false COPY . . RUN npm run build RUN npm prune --production # Production stage FROM node:20-alpine WORKDIR /app RUN addgroup -g 1001 -S appgroup && adduser -u 1001 -S appuser -G appgroup COPY /app/dist ./dist COPY /app/node_modules ./node_modules COPY /app/package.json ./ USER appuser EXPOSE 3000 HEALTHCHECK CMD wget -qO- http://localhost:3000/health || exit 1 CMD ["node", "dist/index.js"]
Pipeline Best Practices
Speed Optimization
- Cache dependencies — Use
actions/cacheor built-incacheoption - Run jobs in parallel — Lint, test, and security scan concurrently
- Skip unchanged code — Use path filters to skip irrelevant jobs
- Cancel stale runs — Use
concurrencyto cancel outdated workflows - Use smaller runners —
ubuntu-latestis usually sufficient
Security
- Pin action versions — Use SHA, not tags:
actions/checkout@abc123 - Minimize permissions — Set
permissions: read-allat workflow level - Use environment secrets — Not repository secrets for deployment credentials
- Require approval — Use environment protection rules for production
- Scan dependencies — Run
npm auditand CodeQL in CI
Reliability
- Don't cancel deployments — Use
cancel-in-progress: falsefor deploy jobs - Add smoke tests — Verify deployment with health checks
- Use timeouts — Set
timeout-minuteson long-running jobs - Notify on failure — Slack, email, or PagerDuty alerts
- Keep pipelines fast — Target < 10 minutes for CI, < 20 for full CD
Cost Optimization
# Use path filters to avoid unnecessary runs on: push: paths-ignore: - '**.md' - 'docs/**' - '.github/ISSUE_TEMPLATE/**' # Use smaller machines when possible runs-on: ubuntu-latest # Not ubuntu-latest-large unless needed # Cache aggressively - uses: actions/setup-node@v4 with: cache: 'npm' # Built-in caching
Required Secrets
| Secret | Used For | Where to Set |
|---|---|---|
GITHUB_TOKEN | Auto-provided | Built-in |
AWS_ACCESS_KEY_ID | AWS deployment | Repository secrets |
AWS_SECRET_ACCESS_KEY | AWS deployment | Repository secrets |
VERCEL_TOKEN | Vercel deployment | Repository secrets |
SLACK_WEBHOOK | Notifications | Repository secrets |
SSH_PRIVATE_KEY | VPS deployment | Environment secrets |
KUBECONFIG | Kubernetes | Environment secrets |
DOCKER_USERNAME | Docker Hub | Repository secrets |
DOCKER_PASSWORD | Docker Hub | Repository secrets |
Monitoring & Notifications
# Post-deployment notification - name: Notify Slack if: always() uses: 8398a7/action-slack@v3 with: status: ${{ job.status }} fields: repo,commit,author,workflow mention: 'here' if_mention: failure env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
Act Action
Streamline your workflow with this execute, github, actions, locally. Includes structured workflows, validation checks, and reusable patterns for automation.