Production-ready CI/CD pipeline templates for GitHub Actions, covering Docker, Terraform, Python, and Kubernetes deployments.
This repository contains battle-tested CI/CD templates that implement security scanning, testing, and deployment best practices. Each template is designed to be copied and customized for your specific needs.
| Template | Description | Features |
|---|---|---|
| Docker | Build, scan, and push container images | Multi-arch builds, Trivy scanning, GHCR/DockerHub |
| Terraform | Infrastructure as Code pipelines | Format, validate, plan, apply with state locking |
| Python | Python application CI/CD | pytest, coverage, linting, PyPI publishing |
| Kubernetes | K8s deployment pipelines | Helm, Kustomize, ArgoCD integration |
flowchart LR
subgraph Trigger
Push[Push/PR]
end
subgraph CI[Continuous Integration]
Lint[Lint & Format]
Test[Test & Coverage]
Scan[Security Scan]
Build[Build Artifacts]
end
subgraph CD[Continuous Deployment]
Dev[Dev Environment<br/>Auto Deploy]
Staging[Staging<br/>Auto Deploy]
Prod[Production<br/>Manual Approval]
end
Push --> Lint --> Test --> Scan --> Build
Build --> Dev --> Staging --> Prod
style Lint fill:#2088FF,color:#fff
style Test fill:#2088FF,color:#fff
style Scan fill:#e74c3c,color:#fff
style Build fill:#27ae60,color:#fff
style Prod fill:#f39c12,color:#fff
flowchart TB
subgraph GitHub Actions
direction TB
subgraph Docker Pipeline
D1[Hadolint] --> D2[Build Image]
D2 --> D3[Trivy Scan]
D3 --> D4[Push GHCR]
end
subgraph Terraform Pipeline
T1[fmt + validate] --> T2[tfsec]
T2 --> T3[Plan]
T3 --> T4[Apply]
end
subgraph Python Pipeline
P1[Ruff + mypy] --> P2[pytest]
P2 --> P3[Safety]
P3 --> P4[PyPI]
end
subgraph K8s Pipeline
K1[Helm Lint] --> K2[Dry Run]
K2 --> K3[Deploy Dev]
K3 --> K4[Deploy Prod]
end
end
style D3 fill:#e74c3c,color:#fff
style T2 fill:#e74c3c,color:#fff
style P3 fill:#e74c3c,color:#fff
# For a Docker project
cp -r templates/docker/.github/workflows/* your-project/.github/workflows/
# For a Terraform project
cp -r templates/terraform/.github/workflows/* your-project/.github/workflows/
# For a Python project
cp -r templates/python/.github/workflows/* your-project/.github/workflows/Add these secrets to your repository (Settings → Secrets → Actions):
| Secret | Required For | Description |
|---|---|---|
DOCKERHUB_USERNAME |
Docker | Docker Hub username |
DOCKERHUB_TOKEN |
Docker | Docker Hub access token |
AWS_ACCESS_KEY_ID |
Terraform | AWS credentials |
AWS_SECRET_ACCESS_KEY |
Terraform | AWS credentials |
PYPI_API_TOKEN |
Python | PyPI publishing token |
KUBECONFIG |
Kubernetes | Base64 encoded kubeconfig |
Each template includes comments explaining customization options.
# Triggers on push to main and PRs
# Features:
# - Multi-stage build optimization
# - Trivy vulnerability scanning
# - Multi-architecture builds (amd64, arm64)
# - Push to GitHub Container Registry
# - Semantic versioning with tagsWorkflow stages:
- Lint - Dockerfile linting with Hadolint
- Build - Multi-stage Docker build
- Scan - Trivy security scanning
- Push - Push to GHCR/DockerHub
- Deploy - Optional deployment trigger
# Triggers on push to main and PRs
# Features:
# - Terraform fmt and validate
# - tfsec security scanning
# - Infracost cost estimation
# - Plan output in PR comments
# - Manual apply approval for productionWorkflow stages:
- Format - Check Terraform formatting
- Validate - Syntax validation
- Security - tfsec and checkov scanning
- Plan - Generate execution plan
- Cost - Infracost estimation
- Apply - Apply with manual approval
# Triggers on push to main and PRs
# Features:
# - Multi-version Python testing (3.9, 3.10, 3.11)
# - pytest with coverage reporting
# - Ruff linting and formatting
# - Type checking with mypy
# - Dependency scanning with safety
# - PyPI publishing on releaseWorkflow stages:
- Lint - Ruff linting and formatting
- Type Check - mypy static analysis
- Test - pytest with coverage
- Security - safety dependency scan
- Build - Build wheel/sdist
- Publish - PyPI release
# Triggers on push to main and PRs
# Features:
# - Helm chart linting and testing
# - Kubernetes manifest validation
# - Kustomize build verification
# - Deployment to multiple environments
# - ArgoCD sync supportWorkflow stages:
- Lint - Helm lint, kubeval
- Test - Helm test, dry-run
- Build - Package Helm chart
- Deploy Dev - Auto-deploy to dev
- Deploy Staging - Auto-deploy to staging
- Deploy Prod - Manual approval required
- Secret scanning - GitHub secret scanning enabled
- Dependency scanning - Dependabot configured
- Container scanning - Trivy for vulnerabilities
- IaC scanning - tfsec, checkov for Terraform
- SAST - CodeQL for code analysis
- Code coverage - Minimum thresholds enforced
- Linting - Language-specific linters
- Formatting - Automated code formatting
- Type checking - Static type analysis
- Environment protection - Required reviewers for production
- Rollback capability - Easy rollback procedures
- Canary deployments - Gradual rollout support
- Feature flags - Integration with feature flag services
cicd-pipeline-templates/
├── README.md
├── LICENSE
├── .github/
│ └── workflows/
│ └── validate.yml # Validates all templates
├── templates/
│ ├── docker/
│ │ ├── README.md
│ │ └── .github/workflows/
│ │ ├── docker-build.yml
│ │ └── docker-security.yml
│ ├── terraform/
│ │ ├── README.md
│ │ └── .github/workflows/
│ │ ├── terraform-plan.yml
│ │ └── terraform-apply.yml
│ ├── python/
│ │ ├── README.md
│ │ └── .github/workflows/
│ │ ├── python-test.yml
│ │ └── python-publish.yml
│ └── kubernetes/
│ ├── README.md
│ └── .github/workflows/
│ ├── helm-test.yml
│ └── k8s-deploy.yml
└── examples/
└── complete-pipeline.yml # Full example combining templates
name: Docker Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
uses: morgandt-reed/cicd-pipeline-templates/.github/workflows/docker-build.yml@main
with:
image-name: my-app
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}name: Infrastructure
on:
push:
branches: [main]
paths: ['terraform/**']
jobs:
plan:
uses: morgandt-reed/cicd-pipeline-templates/.github/workflows/terraform-plan.yml@main
with:
working-directory: terraform/environments/prod
secrets:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}Contributions are welcome! Please read the contributing guidelines before submitting PRs.
MIT License - see LICENSE for details.
- docker-microservices-template - Uses Docker pipeline
- infrastructure-as-code-demos - Uses Terraform pipeline
- langgraph-rag-assistant - Uses Python pipeline
- kubernetes-deployment-patterns - Uses Kubernetes pipeline