home / skills / louloulin / claude-agent-sdk / deployment-automation

This skill designs and implements CI/CD pipelines across GitHub Actions and GitLab, optimizing build, test, deploy automation for Rust applications.

npx playbooks add skill louloulin/claude-agent-sdk --skill deployment-automation

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
5.5 KB
---
name: deployment-automation
description: "Automated deployment pipeline and CI/CD workflow expert"
version: "2.0.0"
author: "DevOps Team <[email protected]>"
tags:
  - deployment
  - cicd
  - automation
  - devops
dependencies:
  - docker-helper
  - git-workflow
---

# Deployment Automation Skill

You are a deployment automation expert. Help design and implement CI/CD pipelines.

## CI/CD Platforms

### GitHub Actions
```yaml
name: deployment-automation

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

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - run: npm ci
      - run: npm test
      - run: npm run lint

  build:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: docker build -t myapp:${{ github.sha }} .
      - run: docker tag myapp:${{ github.sha }} myapp:latest

  deploy:
    needs: build
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - run: docker push myapp:${{ github.sha }}
      - run: kubectl set image deployment/myapp myapp=myapp:${{ github.sha }}
```

### GitLab CI
```yaml
stages:
  - test
  - build
  - deploy

test:
  stage: test
  image: node:20
  script:
    - npm ci
    - npm test
    - npm run lint

build:
  stage: build
  image: docker:latest
  services:
    - docker:dind
  script:
    - docker build -t myapp:$CI_COMMIT_SHA .
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker push myapp:$CI_COMMIT_SHA

deploy:staging:
  stage: deploy
  script:
    - kubectl set image deployment/myapp myapp=myapp:$CI_COMMIT_SHA
  environment:
    name: staging
  only:
    - develop

deploy:production:
  stage: deploy
  script:
    - kubectl set image deployment/myapp myapp=myapp:$CI_COMMIT_SHA
  environment:
    name: production
  when: manual
  only:
    - main
```

## Deployment Strategies

### 1. Blue-Green Deployment
- Run two identical environments (blue and green)
- Deploy to inactive environment
- Test thoroughly
- Switch traffic with DNS/load balancer
- Keep old environment for rollback

**Pros:**
- Zero downtime
- Instant rollback
- Easy testing

**Cons:**
- Double resource cost
- Complex setup

### 2. Rolling Deployment
- Deploy to subset of instances
- Gradually replace old version
- Monitor health
- Continue or rollback

**Pros:**
- Resource efficient
- Gradual rollout
- Easy to implement

**Cons:**
- Slower rollback
- Version coexistence during rollout

### 3. Canary Deployment
- Deploy to small percentage of users
- Monitor metrics carefully
- Gradually increase traffic
- Full rollout or rollback

**Pros:**
- Risk mitigation
- Real user testing
- Easy rollback

**Cons:**
- Complex monitoring
- Longer deployment time

### 4. Feature Flags
- Deploy code behind flags
- Enable features incrementally
- Kill switch for problems
- A/B testing support

**Pros:**
- Maximum control
- Instant rollback
- Testing flexibility

**Cons:**
- Code complexity
- Flag management overhead

## Pipeline Stages

### Stage 1: Build
```yaml
build:
  script:
    - npm ci
    - npm run build
  artifacts:
    paths:
      - dist/
    expire_in: 1 week
```

### Stage 2: Test
```yaml
test:unit:
  script:
    - npm run test:unit

test:integration:
  script:
    - npm run test:integration

test:e2e:
  script:
    - npm run test:e2e
```

### Stage 3: Security Scan
```yaml
security:
  script:
    - npm audit
    - trivy fs .
    - semgrep --config=auto .
```

### Stage 4: Deploy
```yaml
deploy:staging:
  environment:
    name: staging
    url: https://staging.example.com
  script:
    - ./deploy.sh staging
  only:
    - develop

deploy:production:
  environment:
    name: production
    url: https://example.com
  script:
    - ./deploy.sh production
  when: manual
  only:
    - main
```

## Quality Gates

### Automated Checks
- [ ] All tests pass
- [ ] Code coverage > 80%
- [ ] No security vulnerabilities
- [ ] No linting errors
- [ ] Performance benchmarks met
- [ ] Documentation updated

### Manual Approvals
- [ ] Code review approved
- [ ] Product owner approval
- [ ] Security team sign-off (for sensitive changes)
- [ ] Performance team review (for major changes)

## Monitoring & Rollback

### Deployment Metrics
- Deployment frequency
- Lead time for changes
- Change failure rate
- Mean time to recovery (MTTR)

### Health Checks
```yaml
livenessProbe:
  httpGet:
    path: /health
    port: 3000
  initialDelaySeconds: 30
  periodSeconds: 10

readinessProbe:
  httpGet:
    path: /ready
    port: 3000
  initialDelaySeconds: 5
  periodSeconds: 5
```

### Rollback Triggers
- Error rate > 1%
- Response time > 2x baseline
- CPU/Memory > 90%
- Failed health checks
- Manual trigger

## Secrets Management

### Environment Variables
```yaml
deploy:
  variables:
    DATABASE_URL: $DATABASE_URL
    API_KEY: $API_KEY
  script:
    - ./deploy.sh
```

### Secure Files
```yaml
deploy:
  script:
    - openssl aes-256-cbc -d -in secrets.tar.enc -out secrets.tar -k $KEY
    - tar xvf secrets.tar
    - ./deploy.sh
```

## Best Practices

āœ… **DO:**
- Automate everything possible
- Use infrastructure as code
- Test in production-like environment
- Monitor deployments closely
- Have rollback plans
- Use semantic versioning
- Document deployment process
- Keep secrets secure

āŒ **DON'T:**
- Deploy without testing
- Skip staging environment
- Ignore failed deployments
- Store secrets in repo
- Deploy on Fridays (unless necessary)
- Skip monitoring
- Rollback without investigation

Overview

This skill provides practical guidance and templates for designing automated deployment pipelines and CI/CD workflows, with examples for GitHub Actions and GitLab CI. It focuses on build, test, security scanning, deployment strategies, monitoring, and rollback procedures. The content is tailored to modern containerized deployments and works well for Rust-based services and container images.

How this skill works

The skill inspects common CI/CD stages and recommends concrete job configurations, health checks, and secrets handling patterns. It provides deployment strategy advice (blue-green, rolling, canary, feature flags) and quality gates to enforce tests, coverage, and security scans. Example manifests show how to build, test, scan, and deploy Docker images to Kubernetes with conditional promotions and manual gates.

When to use it

  • Setting up CI/CD for a Rust microservice or monorepo producing Docker images
  • Creating automated pipelines that run tests, linters, and security scans before deployment
  • Deploying to Kubernetes with controlled rollouts and health checks
  • Implementing feature flags, canaries, or blue-green strategies to reduce risk
  • Defining quality gates and manual approvals for production releases

Best practices

  • Automate everything repeatable: builds, tests, scans, and deployments
  • Use infrastructure-as-code and immutable container images for reproducible releases
  • Run tests and security scans early; fail fast on linting, vulnerability, or coverage regressions
  • Use health checks (liveness/readiness) and metrics to trigger automated rollbacks
  • Store secrets in the CI/CD platform or a secrets manager; never commit them to repo
  • Document deployment steps, rollback plans, and manual approval criteria

Example use cases

  • GitHub Actions pipeline: run node/rust build/test jobs, dockerize artifact, push image, kubectl rollout on main branch
  • GitLab CI pipeline: test in containers, build with docker:dind, push image to registry, staged deploys for develop and manual production deploys
  • Canary rollout: update a small subset of pods, monitor error and latency metrics, gradually increase traffic or rollback
  • Blue-green deployment: provision parallel environment, validate new version, switch load balancer on success for instant rollback capability
  • Feature flags: deploy behind flags to separate release from enablement and use kill switches for rapid mitigation

FAQ

How do I choose between blue-green, rolling, and canary?

Choose based on risk tolerance and resources: blue-green gives instant rollback but doubles resources; rolling is resource-efficient; canary is best when you can monitor user impact and want gradual exposure.

What automated checks should block a deploy?

Fail deployments on failing tests, lint errors, critical security vulnerabilities, and failing performance benchmarks or degraded health checks; require manual approval for sensitive production changes.