Overview#
The CI/CD Pipeline Automation project demonstrates how to build a complete automated workflow that handles testing, building, security scanning, and deployment of applications. This project showcases DevOps best practices and infrastructure-as-code principles.
Problem Statement#
Manual deployment processes are error-prone, time-consuming, and inconsistent. This project automates the entire software delivery pipeline to enable:
- Fast, reliable deployments
- Consistent build environments
- Automated testing and quality gates
- Security scanning before deployment
- Rollback capabilities
- Deployment notifications and monitoring
Technologies Used#
- GitHub Actions - CI/CD workflow automation
- Docker - Containerization of applications
- Kubernetes - Container orchestration
- Helm - Kubernetes package management
- Terraform - Infrastructure as Code
- SonarQube - Code quality and security analysis
- Trivy - Container vulnerability scanning
- Prometheus & Grafana - Monitoring and alerting
- ArgoCD - GitOps continuous deployment
Pipeline Stages#
graph LR
A[Code Push] --> B[Lint & Test]
B --> C{Tests Pass?}
C -->|Yes| D[Build Docker Image]
C -->|No| Z[Notify Failure]
D --> E[Security Scan]
E --> F{Vulnerabilities?}
F -->|None/Critical=0| G[Push to Registry]
F -->|Critical Found| Z
G --> H[Deploy to Staging]
H --> I[Integration Tests]
I --> J{Tests Pass?}
J -->|Yes| K[Deploy to Production]
J -->|No| Z
K --> L[Health Checks]
L --> M[Notify Success]GitHub Actions Workflow#
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test -- --coverage
- name: Upload coverage
uses: codecov/codecov-action@v3
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t myapp:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'myapp:${{ github.sha }}'
format: 'table'
exit-code: '1'
ignore-unfixed: true
severity: 'CRITICAL'
- name: Push to registry
run: |
docker tag myapp:${{ github.sha }} registry.example.com/myapp:${{ github.sha }}
docker push registry.example.com/myapp:${{ github.sha }}
deploy:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Deploy to Kubernetes
uses: azure/setup-kubectl@v3
- name: Update deployment
run: |
kubectl set image deployment/myapp \
myapp=registry.example.com/myapp:${{ github.sha }} \
-n production
kubectl rollout status deployment/myapp -n production --timeout=300sInfrastructure as Code#
Terraform Configuration#
resource "aws_eks_cluster" "main" {
name = "production-cluster"
role_arn = aws_iam_role.eks_cluster.arn
vpc_config {
subnet_ids = aws_subnet.private[*].id
}
}
resource "helm_release" "application" {
name = "myapp"
repository = "https://charts.example.com"
chart = "myapp"
namespace = "production"
set {
name = "image.tag"
value = var.app_version
}
}Kubernetes Deployment#
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: production
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
spec:
containers:
- name: myapp
image: registry.example.com/myapp:latest
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5Getting Started#
Prerequisites#
- GitHub repository
- Docker installed locally
- kubectl configured for your cluster
- AWS/GCP/Azure account (for cloud resources)
Local Development#
# Clone the repository
git clone https://github.com/jahruhn/cicd-pipeline.git
cd cicd-pipeline
# Start local Kubernetes (Docker Desktop or kind)
kubectl cluster-info
# Deploy locally
helm install myapp ./charts/myapp \
--namespace development \
--create-namespace
# Port-forward to access locally
kubectl port-forward svc/myapp 8080:80 -n developmentSet Up GitHub Actions#
Add repository secrets:
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY DOCKER_REGISTRY_PASSWORD KUBE_CONFIG_DATAPush to main branch to trigger pipeline
Monitoring & Observability#
Prometheus Metrics#
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: myapp
spec:
selector:
matchLabels:
app: myapp
endpoints:
- port: metrics
interval: 15sGrafana Dashboard#
Key metrics tracked:
- Deployment frequency
- Deployment success rate
- Mean time to recovery (MTTR)
- Lead time for changes
- Application performance (latency, throughput, errors)
Challenges & Learnings#
Secrets Management: Initially stored secrets in GitHub Actions, but migrated to HashiCorp Vault for better security, auditability, and rotation policies.
Rollback Strategy: Implemented automatic rollback when health checks fail after deployment. Learned the importance of database migration strategies that support both forward and backward compatibility during rollbacks.
Pipeline Performance: Optimized pipeline execution time from 25 minutes to 8 minutes by:
- Implementing job parallelization
- Caching dependencies
- Using faster runners
- Conditional job execution
Best Practices Implemented#
✅ Immutable Deployments: Each build creates a new Docker image with unique tag
✅ Infrastructure as Code: All infrastructure defined in version-controlled files
✅ Environment Parity: Local, staging, and production environments are identical
✅ Automated Rollbacks: Health check failures trigger automatic rollback
✅ Security First: Vulnerability scanning before deployment
✅ Observability: Comprehensive logging, metrics, and tracing
✅ Documentation: Runbooks for common operational tasks
Future Enhancements#
- Implement canary deployments
- Add chaos engineering tests
- Multi-region deployment support
- GitOps with ArgoCD (instead of push-based deploys)
- Cost monitoring and optimization
- Automated performance testing in pipeline
Links#
- Source Code: GitHub Repository
- Documentation: Pipeline Docs
- Terraform Modules: Infrastructure Code
💡 Note: This is a sample project demonstrating DevOps skills. Replace with your actual CI/CD implementation and update all links.

