Design and implement production-grade CI/CD pipelines with GitHub Actions, layered testing strategies, secure deployment patterns, and environment management.
npx skills add https://github.com/cosmicstack-labs/mercury-agent-skills --skill ci-cd-pipeline
CI/CD pipelines are the backbone of modern software delivery — the automated assembly line that transforms source code into running software. A well-designed pipeline catches bugs early, enforces quality gates, deploys with confidence, and gives developers fast feedback. This skill covers the full spectrum from GitHub Actions workflow authoring and matrix build strategies to multi-environment deployment patterns, secret management, and pipeline security.
git push and SSHTypical Beginner Workflow:
name: Deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install
- run: npm run build
- run: npm test
- run: scp -r dist/ user@server:/var/www/
actions/cache or setup-node --cacheproduction requires approval)Proficient Structure:
name: CI/CD
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
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
test:
needs: lint
strategy:
matrix:
node: [18, 20, 22]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm run test:unit
- run: npm run test:integration
build:
needs: test
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker.outputs.image }}
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- id: docker
run: |
docker build -t app:${{ github.sha }} .
echo "image=app:${{ github.sha }}" >> $GITHUB_OUTPUT
deploy-staging:
needs: build
environment: staging
runs-on: ubuntu-latest
steps:
- run: echo "Deploy ${{ needs.build.outputs.image }} to staging"
deploy-production:
needs: deploy-staging
environment: production
runs-on: ubuntu-latest
steps:
- run: echo "Deploy ${{ needs.build.outputs.image }} to production"
Expert Pattern — Reusable Deploy Workflow:
# .github/workflows/deploy.yml — reusable
name: Deploy to Environment
on:
workflow_call:
inputs:
environment:
required: true
type: string
image-tag:
required: true
type: string
secrets:
cloud-role-arn:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
concurrency: deploy-${{ inputs.environment }}
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.cloud-role-arn }}
aws-region: us-east-1
- run: |
aws eks update-kubeconfig --name cluster-${{ inputs.environment }}
kubectl set image deployment/app app=${{ inputs.image-tag }}
- run: |
kubectl rollout status deployment/app --timeout=5m
Calling the reusable workflow:
jobs:
deploy-staging:
uses: ./.github/workflows/deploy.yml
with:
environment: staging
image-tag: ${{ needs.build.outputs.image-tag }}
secrets:
cloud-role-arn: ${{ secrets.STAGING_ROLE_ARN }}
Workflow Structure Best Practices:
CI - Lint & Test, CD - Deploy Productionconcurrency to cancel redundant runs on the same branchactions/checkout with fetch-depth: 0 only when needed (default fetch-depth: 1 is faster)name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Path Triggers for Monorepos:
on:
push:
paths:
- "services/api/**"
- "packages/shared/**"
- ".github/workflows/api-ci.yml"
Matrix builds test across multiple versions, platforms, and configurations simultaneously.
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node: [18, 20, 22]
include:
- os: ubuntu-latest
node: 20
coverage: true
exclude:
- os: windows-latest
node: 18
Dynamic Matrix from Changed Files:
jobs:
detect:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.filter.outputs.changes }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
api: services/api/**
web: services/web/**
worker: services/worker/**
test:
needs: detect
strategy:
matrix:
service: ${{ fromJson(needs.detect.outputs.services) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cd services/${{ matrix.service }} && npm ci && npm test
Dependency Caching:
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: services/api/package-lock.json
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
.venv
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
Docker Layer Caching:
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: app:${{ github.sha }}
Organize tests from fastest to slowest. The pipeline should fail as early as possible.
| Stage | Tools | Time Budget | Fail Behavior |
|-------|-------|-------------|---------------|
| Lint | ESLint, Prettier, Ruff, hadolint | <30s | Immediate block |
| Type Check | TypeScript, mypy, Pyright | <1m | Block |
| Unit Tests | Vitest, Jest, pytest, Go test | <3m | Block |
| Integration Tests | Supertest, Testcontainers, Docker Compose | <5m | Block |
| Security Scan | Trivy, Snyk, CodeQL | <3m | Block on critical |
| E2E Tests | Playwright, Cypress, Selenium | <15m | Block |
jobs:
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: npx tsc --noEmit
unit:
needs: 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 test:unit -- --coverage
- uses: codecov/codecov-action@v4
with:
files: coverage/lcov.info
integration:
needs: unit
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: testdb
POSTGRES_PASSWORD: testpass
options: >-
--health-cmd pg_isready
--health-interval 5s
redis:
image: redis:7-alpine
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run test:integration
e2e:
needs: integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
docker compose -f compose.ci.yml up -d
npx playwright test
Use GitHub Environments to enforce protection rules and track deployments.
environment:
name: production
url: https://app.example.com
Configure protection rules in GitHub UI:
main)Environment-Specific Secrets:
jobs:
deploy:
environment: production
runs-on: ubuntu-latest
steps:
- run: deploy.sh
env:
API_KEY: ${{ secrets.PRODUCTION_API_KEY }}
Bad — Secrets in plaintext:
- run: curl -H "Authorization: Bearer supersecret123"
Good — GitHub Secrets:
- run: deploy.sh
env:
API_KEY: ${{ secrets.API_KEY }}
Best — OIDC Authentication (no static secrets):
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456:role/github-actions-deploy
aws-region: us-east-1
Secret Detection in CI:
- uses: trufflesecurity/trufflehog@v3
with:
extra-args: --results=verified,failed
jobs:
deploy-staging:
environment: staging
runs-on: ubuntu-latest
steps:
- run: echo "Deploying to staging..."
deploy-production:
needs: deploy-staging
environment:
name: production
runs-on: ubuntu-latest
steps:
- run: echo "Deploying to production..."
With manual approval configured on the production environment in GitHub UI, the pipeline pauses before the deploy-production job until an authorized user approves.
Never rebuild for each environment. Build the artifact once, store it, and promote it.
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: docker build -t app:${{ github.sha }} .
- run: docker push registry.example.com/app:${{ github.sha }}
deploy-staging:
needs: build
steps:
- run: docker pull registry.example.com/app:${{ github.sha }}
- run: deploy-to-staging.sh ${{ github.sha }}
deploy-production:
needs: deploy-staging
environment: production
steps:
- run: docker pull registry.example.com/app:${{ github.sha }}
- run: deploy-to-production.sh ${{ github.sha }}
actions/cache or built-in caching for package managers.uses: actions/checkout@v3 instead of @v3.0.0) can be compromised. Use full version tags or SHAs.concurrency, pushing three commits in quick succession creates three simultaneous deployments to the same environment, causing race conditions.10. No rollback strategy — Deployments fail. Without an automated rollback mechanism (blue/green, canary, or direct rollback), a bad deployment becomes an incident.
Assess Kubernetes workloads and cluster configuration for AKS Automatic compatibility. Identifies incompatibilities, generates fixes, and guides migration from AKS Standard to AKS Automatic. WHEN: migrate to AKS Automatic, check AKS Automatic readiness, validate manifests for Automatic, assess cluster for Automatic compatibility, fix deployment for Automatic compatibility, identify AKS Automatic migration blockers, is my cluster ready for AKS Automatic.
Discovers available Azure OpenAI model capacity across regions and projects. Analyzes quota limits, compares availability, and recommends optimal deployment locations based on capacity requirements. USE FOR: find capacity, check quota, where can I deploy, capacity discovery, best region for capacity, multi-project capacity search, quota analysis, model availability, region comparison, check TPM availability. DO NOT USE FOR: actual deployment (hand off to preset or customize after discovery), quota increase requests (direct user to Azure Portal), listing existing deployments.
Interactive guided deployment flow for Azure OpenAI models with full customization control. Step-by-step selection of model version, SKU (GlobalStandard/Standard/ProvisionedManaged), capacity, RAI policy (content filter), and advanced options (dynamic quota, priority processing, spillover). USE FOR: custom deployment, customize model deployment, choose version, select SKU, set capacity, configure content filter, RAI policy, deployment options, detailed deployment, advanced deployment, PTU deployment, provisioned throughput. DO NOT USE FOR: quick deployment to optimal region (use preset).
Unified Azure OpenAI model deployment skill with intelligent intent-based routing. Handles quick preset deployments, fully customized deployments (version/SKU/capacity/RAI policy), and capacity discovery across regions and projects. USE FOR: deploy model, deploy gpt, create deployment, model deployment, deploy openai model, set up model, provision model, find capacity, check model availability, where can I deploy, best region for model, capacity analysis. DO NOT USE FOR: listing existing deployments (use foundry_models_deployments_list MCP tool), deleting deployments, agent creation (use agent/create), project creation (use project/create).
Intelligently deploys Azure OpenAI models to optimal regions by analyzing capacity across all available regions. Automatically checks current region first and shows alternatives if needed. USE FOR: quick deployment, optimal region, best region, automatic region selection, fast setup, multi-region capacity check, high availability deployment, deploy to best location. DO NOT USE FOR: custom SKU selection (use customize), specific version selection (use customize), custom capacity configuration (use customize), PTU deployments (use customize).
This skill should be used when working with LaminDB, an open-source data framework for biology that makes data queryable, traceable, reproducible, and FAIR. Use when managing biological datasets (scRNA-seq, spatial, flow cytometry, etc.), tracking computational workflows, curating and validating data with biological ontologies, building data lakehouses, or ensuring data lineage and reproducibility in biological research. Covers data management, annotation, ontologies (genes, cell types, diseases, tissues), schema validation, integrations with workflow managers (Nextflow, Snakemake) and MLOps platforms (W&B, MLflow), and deployment strategies.
Latch platform for bioinformatics workflows. Build pipelines with Latch SDK, @workflow/@task decorators, deploy serverless workflows, LatchFile/LatchDir, Nextflow/Snakemake integration.
Run Python code in the cloud with serverless containers, GPUs, and autoscaling. Use when deploying ML models, running batch processing jobs, scheduling compute-intensive tasks, or serving APIs that require GPU acceleration or dynamic scaling.
Take cosmicstack-labs/ci-cd-pipeline from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference npm, npx.
Without those the skill loads but fails at the first command.