CI/CD Workflows¶
This project includes 10 GitHub Actions workflows for automation.
Workflow Overview¶
| Workflow | File | Trigger | Purpose |
|---|---|---|---|
| Deploy EKS | deploy-eks.yml | Manual | Terraform plan/apply/destroy |
| Deploy App | deploy-k8s-app.yml | Manual | K8s app deploy/rollback |
| Pre-commit | pre-commit-ci.yaml | PR | Pre-commit checks + auto-fix |
| Security | checkov.yaml | PR/Push | Checkov security scanning |
| Cost | infracost.yaml | PR | Cost estimation |
| TF Docs | tf-docs.yaml | PR | Auto-generate Terraform docs |
| Secrets | gitleaks.yaml | PR/Push | Secret detection |
| Release | release.yaml | Push to main | Semantic versioning |
| Lint PR | lint-pr.yaml | PR | PR title validation |
| Docs | docs-deploy.yaml | Push to main / PR | Build and deploy documentation |
Deploy EKS (deploy-eks.yml)¶
Manually triggered workflow for Terraform operations.
Inputs:
| Input | Options | Description |
|---|---|---|
environment | dev, qa, prod | Target environment |
action | plan, apply, destroy | Terraform action |
Usage:
- Go to Actions → Deploy EKS
- Click Run workflow
- Select environment and action
- Review plan output before applying
# Terraform steps executed
terraform init
terraform fmt -check
terraform validate
terraform plan -var-file=environments/${{ env }}/$${{ env }}.tfvars
terraform apply -var-file=environments/${{ env }}/${{ env }}.tfvars # if action=apply
Destroy Action
The destroy action will permanently delete all infrastructure. Use with extreme caution in production.
Deploy App (deploy-k8s-app.yml)¶
Manually triggered workflow for Kubernetes application deployments.
Inputs:
| Input | Options | Description |
|---|---|---|
environment | dev, qa, prod | Target environment |
app_name | nginx | Application to deploy |
action | deploy, rollback | Deployment action |
Steps:
- Configure AWS credentials
- Update kubeconfig for EKS cluster
- Build Kustomize manifests
- Apply or rollback deployment
Pre-commit CI (pre-commit-ci.yaml)¶
Runs all pre-commit hooks on pull requests and auto-commits any formatting fixes.
Tools installed:
- Python 3.10
- Terraform 1.10.5
- TFLint
- terraform-docs
- Checkov
- Gitleaks
- pre-commit
Auto-fix: If hooks modify files (e.g., terraform fmt, terraform-docs), changes are automatically committed back to the PR branch.
Security Scan (checkov.yaml)¶
Runs Checkov security scanning on all Terraform configurations.
- Outputs results as JSON artifact (30-day retention)
- Soft-fail mode: reports issues without blocking merges
- Configuration via
.checkov.yml
Cost Estimation (infracost.yaml)¶
Posts infrastructure cost estimates as PR comments.
Requirements: INFRACOST_API_KEY secret must be set.
Output: Shows monthly cost breakdown and diff between base and PR branch.
Terraform Docs (tf-docs.yaml)¶
Auto-generates Terraform documentation in README.md between BEGIN_TF_DOCS and END_TF_DOCS markers.
Secret Detection (gitleaks.yaml)¶
Scans commits and PR diffs for hardcoded secrets.
Requirements: GITLEAKS_LICENSE secret (optional for private repos).
Release (release.yaml)¶
Automated semantic versioning on push to main.
Process:
- Analyzes commits since last release
- Determines version bump (major/minor/patch)
- Updates
CHANGELOG.md - Creates GitHub Release with release notes
- Tags the release
Requires: WORKFLOW_TOKEN secret with contents: write permission.
PR Lint (lint-pr.yaml)¶
Validates PR titles follow Conventional Commits format.
Allowed types: fix, feat, docs, ci, chore, style, refactor, test, revert
Posts a sticky comment on validation failures with guidance.
Documentation (docs-deploy.yaml)¶
Builds and deploys MkDocs documentation to GitHub Pages.
Triggers: - Push to main (when docs files change) → build + deploy - Pull request → build only (validation) - Manual dispatch → build + deploy
Process:
- Install Python dependencies (
requirements.txt) - Auto-configure repository URLs from
GITHUB_REPOSITORY - Commit URL changes back to repository
- Build documentation with
mkdocs build --strict - Deploy to GitHub Pages (on push to main)
Setup: Enable GitHub Pages in repository settings with source set to GitHub Actions.
Required GitHub Secrets¶
| Secret | Required | Description |
|---|---|---|
AWS_ACCESS_KEY_ID | Yes | AWS access key for deployments |
AWS_SECRET_ACCESS_KEY | Yes | AWS secret key for deployments |
AWS_REGION | Yes | AWS region |
INFRACOST_API_KEY | No | Infracost cost estimation |
GITLEAKS_LICENSE | No | Gitleaks for private repos |
WORKFLOW_TOKEN | No | GitHub token for auto-commits |