This directory contains the complete CI/CD pipeline configuration for Paperless Maverick, implementing automated deployment with comprehensive testing, security scanning, and monitoring.
-
ci.yml- Continuous Integration- Code quality checks (ESLint, TypeScript)
- Security scanning (TruffleHog, npm audit, Snyk)
- Unit and integration tests
- Docker image building and pushing
- Container security scanning (Trivy, Grype)
-
deploy-staging.yml- Staging Deployment- Triggered on
developbranch pushes - Pre-deployment validation
- Automated staging deployment
- Post-deployment testing
- Slack notifications
- Triggered on
-
deploy-production.yml- Production Deployment- Triggered on
mainbranch pushes or tags - Manual approval gates (2 approvers required)
- Blue-green deployment strategy
- Comprehensive validation
- Automated rollback on failure
- Triggered on
-
rollback.yml- Emergency Rollback- Manual trigger for emergency situations
- Multi-step rollback capability
- Emergency approval process
- Health validation after rollback
-
security-scan.yml- Security Scanning- Daily automated security scans
- Code analysis (CodeQL)
- Dependency scanning (Snyk, npm audit)
- Container scanning (Trivy, Grype)
- Infrastructure scanning (Checkov)
- Secrets detection (TruffleHog, GitLeaks)
-
monitoring.yml- Production Monitoring- 15-minute health checks
- Performance monitoring
- Critical alert notifications
- System health reporting
Configure the following secrets in your GitHub repository settings:
# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# AI/ML APIs
GEMINI_API_KEY=your_gemini_api_key
OPENAI_API_KEY=your_openai_api_key
# Security
API_KEY_ENCRYPTION_KEY=your_32_byte_encryption_key
JWT_SECRET=your_jwt_secret
# Monitoring
SENTRY_DSN=your_sentry_dsn
GRAFANA_ADMIN_PASSWORD=your_grafana_password
# Notifications
SLACK_WEBHOOK_URL=your_slack_webhook_url
CRITICAL_ALERTS_WEBHOOK_URL=your_critical_alerts_webhook
SECURITY_SLACK_WEBHOOK_URL=your_security_webhook
# Kubernetes
PRODUCTION_KUBECONFIG=base64_encoded_kubeconfig
STAGING_KUBECONFIG=base64_encoded_staging_kubeconfig
# Approvers
PRODUCTION_APPROVERS=user1,user2,user3
EMERGENCY_APPROVERS=user1,user2
# Security Tools
SNYK_TOKEN=your_snyk_token
GITLEAKS_LICENSE=your_gitleaks_license# Staging-specific secrets (prefix with STAGING_)
STAGING_SUPABASE_URL=https://your-staging-project.supabase.co
STAGING_SUPABASE_ANON_KEY=your_staging_anon_key
STAGING_SUPABASE_SERVICE_ROLE_KEY=your_staging_service_role_key
STAGING_GEMINI_API_KEY=your_staging_gemini_key
STAGING_OPENAI_API_KEY=your_staging_openai_key
STAGING_API_KEY_ENCRYPTION_KEY=your_staging_encryption_key
STAGING_JWT_SECRET=your_staging_jwt_secret# Test-specific secrets (prefix with TEST_)
TEST_SUPABASE_URL=https://your-test-project.supabase.co
TEST_SUPABASE_ANON_KEY=your_test_anon_key
TEST_SUPABASE_SERVICE_ROLE_KEY=your_test_service_role_key
TEST_GEMINI_API_KEY=your_test_gemini_keyConfigure branch protection for main and develop branches:
- Require pull request reviews (2 reviewers)
- Require status checks to pass before merging:
Code Quality & SecurityTest SuiteBuild ApplicationBuild Worker ImageSecurity Scan
- Require branches to be up to date before merging
- Restrict pushes to matching branches
- Require signed commits
- Require pull request reviews (1 reviewer)
- Require status checks to pass before merging:
Code Quality & SecurityTest Suite
- Require branches to be up to date before merging
- Name:
production - URL:
https://mataresit.com - Protection Rules:
- Required reviewers: 2
- Deployment branches:
mainonly - Environment secrets: Production secrets
- Name:
staging - URL:
https://staging.mataresit.com - Protection Rules:
- Required reviewers: 1
- Deployment branches:
developonly - Environment secrets: Staging secrets
- Push to
developbranch - CI pipeline runs automatically
- If CI passes, staging deployment triggers
- Automated deployment to staging environment
- Post-deployment tests run
- Slack notification sent
- Create pull request to
mainbranch - Code review and approval (2 reviewers required)
- Merge to
maintriggers production pipeline - Pre-deployment validation runs
- Manual approval required (2 approvers)
- Blue-green deployment to production
- Post-deployment validation
- Success notification or automated rollback
- Go to Actions β Emergency Rollback
- Select environment and rollback steps
- Provide rollback reason
- Emergency approval required (1 approver for production)
- Automated rollback execution
- Health validation
- Incident notifications
- Health Checks: Every 15 minutes
- Performance Tests: Daily
- Security Scans: Daily
- Dependency Checks: On every push
- System health check failures
- Performance degradation
- Security vulnerabilities
- Deployment failures
- High error rates
- Slack: General notifications and alerts
- Critical Alerts: Separate channel for urgent issues
- Security: Dedicated security team notifications
- GitHub Issues: Automatic incident creation
- CodeQL Analysis: Advanced semantic code analysis
- Dependency Scanning: npm audit + Snyk integration
- Secrets Detection: TruffleHog + GitLeaks
- Container Scanning: Trivy + Grype vulnerability scanning
- Infrastructure Scanning: Checkov policy validation
- Image Signing: Docker images signed and verified
- Security Gates: Deployment blocked on critical vulnerabilities
- RBAC: Role-based access control for deployments
- Audit Logging: Complete deployment audit trail
# Check workflow logs
gh run list --workflow=ci.yml
gh run view <run-id> --log
# Re-run failed jobs
gh run rerun <run-id> --failed# Check deployment status
kubectl get deployments -n paperless-maverick
kubectl describe deployment paperless-maverick -n paperless-maverick
# View pod logs
kubectl logs -f deployment/paperless-maverick -n paperless-maverick# View security scan results
gh run view <run-id> --log
# Check GitHub Security tab for detailed findings- Check monitoring dashboard
- Review recent deployments
- Execute emergency rollback if needed
- Escalate to on-call engineer
- Create incident issue
- Review security scan results
- Assess vulnerability impact
- Apply security patches
- Re-run security scans
- Document remediation
- Deployment Frequency: Tracked per environment
- Lead Time: From commit to production
- Mean Time to Recovery: Incident resolution time
- Change Failure Rate: Failed deployment percentage
- Daily: Security scan summary
- Weekly: Deployment metrics
- Monthly: Performance trends
- Quarterly: Security posture review
- GitHub: Source code and CI/CD
- Kubernetes: Container orchestration
- Docker Registry: Container images (GHCR)
- Supabase: Database and backend services
- Slack: Notifications and alerts
- Sentry: Error monitoring
- Grafana: Metrics and dashboards
- GitHub Actions Documentation
- Kubernetes Deployment Guide
- Security Best Practices
- Monitoring Setup Guide
Note: This CI/CD pipeline implements industry best practices for secure, reliable, and automated software delivery with comprehensive monitoring and rollback capabilities.