GitHub Actions Workflows¶
Overview¶
The Coalition Builder uses GitHub Actions for continuous integration and deployment. The workflows are designed for the serverless architecture with Lambda (backend) and Vercel (frontend).
Workflow Files¶
All workflows are located in .github/workflows/:
Deployment Workflows¶
deploy_lambda.yml¶
Deploys the Django backend to AWS Lambda using Zappa.
Triggers:
- Push to
mainordevelopmentbranches - Manual workflow dispatch with environment selection (
dev,prod)
Authentication:
Uses GitHub OIDC to assume the github-actions-{environment} IAM role — no long-lived AWS access keys required. The workflow needs:
AWS_ACCOUNT_ID(variable, per GitHub environment)id-token: writepermission for OIDC
Process:
- Authenticates to AWS via OIDC (
aws-actions/configure-aws-credentials) - Builds Docker image with GeoDjango support
- Pushes to Amazon ECR
- Updates Zappa configuration
- Deploys or updates Lambda function
- Runs health checks
deploy_frontend.yml¶
Deploys the Next.js frontend to Vercel.
Triggers:
- Push to
mainordevelopmentbranches (when frontend files change) - Pull requests (creates preview deployments)
- Manual workflow dispatch
Environment Variables Required:
VERCEL_TOKEN(secret)VERCEL_ORG_ID(secret)VERCEL_PROJECT_ID(secret)PRODUCTION_API_URL(variable)DEVELOPMENT_API_URL(variable)
Process:
- Installs dependencies
- Builds Next.js application
- Deploys to Vercel
- Creates preview URL for PRs
- Runs smoke tests
deploy_infra.yml¶
Plans and applies Terraform infrastructure changes for a selected environment.
Triggers:
- Push to
main(whenterraform/files change) - Pull requests to
main(plan only, no apply) - Manual workflow dispatch with environment selection (
shared,prod,dev)
Authentication:
Uses GitHub OIDC to assume the github-actions-{environment} IAM role. Each environment's Terraform runs in terraform/environments/{env}/ with its own backend config.
Process:
- Determines target environment from branch or manual input
- Waits for Terraform test workflow to pass (on push)
- Authenticates to AWS via OIDC
- Runs
terraform initwith environment-specificbackend.hcl - Runs
terraform plan - Applies changes on
mainbranch pushes (skips on PRs)
deploy_serverless.yml¶
Full-stack deployment of backend (Lambda) and frontend (Vercel).
Triggers:
- Push to
mainordevbranches - Manual workflow dispatch with environment selection (
dev,prod)
Authentication:
Uses GitHub OIDC — same pattern as deploy_lambda.yml.
Process:
- Runs backend tests (non-prod or manual dispatch)
- Authenticates to AWS via OIDC
- Builds and pushes Docker image to ECR
- Deploys backend via Zappa
- Creates cache table, runs migrations, collects static files
- Deploys frontend to Vercel
- Runs smoke tests (health check, Lambda log check)
Management Workflows¶
lambda_management.yml¶
Manages Lambda functions post-deployment.
Actions Available:
tail-logs- View CloudWatch logsrollback- Rollback to previous versionundeploy- Remove Lambda functionschedule- Set up scheduled executionunschedule- Remove scheduled executioninvoke- Manually invoke functioncertify- Certify deployment
Usage:
geodata_import.yml¶
Runs geographic data imports using ECS Fargate.
Import Types:
tiger-states- Import state boundariestiger-counties- Import county boundariestiger-places- Import city/place boundariesall-tiger- Import all TIGER datacustom- Run custom import command
Process:
- Configures import command
- Runs ECS task with geodata-import container
- Streams logs to workflow summary
- Reports success/failure
Testing Workflows¶
test.yml¶
Runs the complete test suite.
Triggers:
- Every push
- Pull requests
Test Coverage:
- Python backend tests (pytest)
- JavaScript frontend tests (Jest)
- TypeScript compilation
- Terraform validation
- Go tests for Terraform modules
security.yml¶
Runs security scans.
Checks:
- Python dependencies (safety)
- JavaScript dependencies (npm audit)
- Docker image scanning
- SAST scanning with CodeQL
Environment Configuration¶
Development Environment¶
Environment: development
Branch: development or feature/*
Lambda Stage: dev
Vercel: Preview deployment
Production Environment¶
Environment: production
Branch: main
Lambda Stage: production
Vercel: Production deployment
Keep-warm: Yes (4 minutes)
X-Ray: Enabled
Setting Up GitHub Environments¶
- Go to Settings → Environments
- Create two environments:
dev,prod - Add environment-specific variables:
Development¶
DOMAIN_NAME=api-dev.yourdomain.com
CERTIFICATE_ARN=arn:aws:acm:us-east-1:...
DEVELOPMENT_API_URL=https://api-dev.yourdomain.com
Production¶
DOMAIN_NAME=api.yourdomain.com
CERTIFICATE_ARN=arn:aws:acm:us-east-1:...
PRODUCTION_API_URL=https://api.yourdomain.com
Manual Deployment¶
Deploy Lambda¶
# Using GitHub Actions
gh workflow run deploy_lambda.yml --ref main
# Using Zappa directly
cd backend
poetry run zappa deploy prod
Deploy Frontend¶
# Using GitHub Actions
gh workflow run deploy_frontend.yml --ref main
# Using Vercel CLI
cd frontend
vercel --prod
Monitoring Deployments¶
View Deployment Status¶
View Logs¶
Rollback Procedures¶
Lambda Rollback¶
# Via GitHub Actions
gh workflow run lambda_management.yml -f action=rollback -f environment=prod
# Via Zappa
poetry run zappa rollback prod -n 1
Vercel Rollback¶
# Via Vercel Dashboard
# Go to project → Deployments → Select previous → Promote to Production
# Via CLI
vercel rollback
Troubleshooting¶
Lambda Deployment Fails¶
- Check OIDC role trust policy allows the GitHub environment/branch
- Verify
AWS_ACCOUNT_IDvariable is set in the GitHub environment - Verify ECR repository exists
- Check Zappa settings syntax
- Review CloudWatch logs
Vercel Deployment Fails¶
- Check Vercel token is valid
- Verify project and org IDs
- Check build logs for errors
- Ensure environment variables are set
Domain Not Working¶
- Verify certificate is validated in ACM
- Check certificate covers the domain
- Run
zappa certifyfor Lambda - Check DNS propagation
Cost Control¶
Dev VPC Endpoints Toggle¶
The dev environment's VPC endpoints (~$22/month) can be disabled when you're not actively developing to save costs. Use the Dev Cost Control workflow:
# Disable VPC endpoints (saves ~$22/mo)
gh workflow run dev_cost_control.yml -f vpc_endpoints=disable
# Re-enable before developing
gh workflow run dev_cost_control.yml -f vpc_endpoints=enable
Or use the GitHub UI: Actions > Dev Cost Control > Run workflow.
When VPC endpoints are disabled, Lambda functions in the dev environment (which run in private subnets with no NAT/internet route) cannot reach Secrets Manager, CloudWatch Logs, or the Geo Places API at all. Re-enable the endpoints before deploying or testing the dev backend.
Cost Monitoring¶
The serverless architecture significantly reduces costs:
- Lambda: Pay per invocation (~$5/month)
- Vercel: Free tier or $20/month Pro
- DynamoDB: Pay per request (~$1/month)
- Total: ~$39/month vs $73/month for ECS
Monitor usage:
- AWS Cost Explorer for Lambda/DynamoDB
- Vercel Analytics for bandwidth
- CloudWatch for detailed metrics