devops-deployment-automation
Dockerization, CI/CD pipelines (GitHub Actions), deployment targets (Vercel, AWS, Railway), and environment management. Use when containerizing apps, setting up automated pipelines, or configuring pro
SKILL.mdskills/devops-deployment-automation/SKILL.md
GitHubDevOps & Deployment Automation
Purpose
Provide production-grade patterns for containerization, automated CI/CD pipelines, and deployment configuration. This skill bridges the gap between "it works locally" and "it runs reliably in production."
When to Use This Skill
Use when:
- Containerizing an application with Docker
- Setting up CI/CD pipelines (GitHub Actions, GitLab CI)
- Configuring deployment to Vercel, AWS, Railway, Fly.io
- Managing environment variables across dev/staging/production
- Debugging deployment failures or build pipeline issues
Do NOT use when:
- Writing application logic (use backend/frontend agents)
- The project will only ever run locally
Phase 1: Containerization (Docker)
Dockerfile Rules
- Multi-stage builds — separate build deps from runtime
- Layer ordering — least-frequently-changed layers first (OS → deps → code)
- No secrets in images — never
COPY .envor useARGfor secrets - .dockerignore — always include:
node_modules,.git,.env*,dist,coverage - Health checks — add
HEALTHCHECKfor orchestrated environments - Pin versions —
node:20.12-alpine, notnode:latest - Non-root user — always
adduserandUSERdirective
Phase 2: CI/CD Pipelines (GitHub Actions)
Pipeline Order
Lint → Typecheck → Test → Build → Deploy — always this order.
Pipeline Rules
- Fail fast — cancel in-progress runs on new commits
- Cache dependencies — use
actions/cacheor built-in cache - Secrets via GitHub Secrets — never hardcode credentials in workflow files
- Branch protection — require CI to pass before merging to main
- Concurrency control — prevent parallel deploys to same environment
Phase 3: Deployment Targets
| Platform | Best For | Key Feature |
|---|---|---|
| Vercel | Next.js / Static | Zero-config, preview deploys |
| Railway | Full-stack | Built-in Postgres, Nixpacks |
| AWS ECS | Production scale | Container orchestration |
| Fly.io | Edge APIs | Global distribution |
Phase 4: Environment Management
Hierarchy
.env.example ← committed, documents required variables (no values)
.env.local ← local dev, never committed
.env.test ← test env, may be committed if no secrets
.env.production ← NEVER committed, managed via platform
Rules
.env.exampleis mandatory — committed with variable names, no secret values.envfiles are gitignored — verify.gitignoreincludes.env*- Validate at startup — use Zod or
envalidto validate required env vars - No optional secrets — crash on startup if a required secret is missing
Behavior Rules
- Never embed secrets in code, Dockerfiles, or CI configs.
- Always include
.dockerignorealongside any Dockerfile. - Always include
.env.examplewhen env vars are required. - Deployments must be reproducible — same commit = same deployment.
Output Format / Delivery
- Output is deployment config code (Dockerfiles, YMLs) and step-by-step CI/CD pipeline logic.
Safety Guardrails
- Secret Exposure Patch: Verify no secret values in plain text. Use
${{ secrets.NAME }}. - Production Deploy Patch: Deployment steps must have
if:condition restricting to main branch. - Docker Security Patch: Use non-root users, never copy
.envinto images. - Self-Rejection Clause: If deployment target is unknown, ABORT OUTPUT and emit: "REJECTED: Cannot generate deployment config without knowing the target platform."
Maintenance Notes
- Created 2026-04-30 as part of the Operational Gap analysis.
- Complements
backend-dev-guidelineswith infrastructure to ship. - Complements
testing-quality-engineeringwith pipeline to enforce tests.