This document outlines the approval-based workflows implemented for the NEPA application to ensure proper oversight and security for critical operations.
Three approval-based workflows have been created to require manual approval before executing sensitive operations:
- Production Deployment - Requires approval for production deployments
- Security Operations - Requires approval for security-sensitive tasks
- Database Operations - Requires approval for database modifications
File: .github/workflows/deploy-production-approval.yml
Triggers:
- Manual workflow dispatch
- Requires version, environment, and deployment notes
Approval Process:
- Pre-deployment checks - Validates tests, build, and security
- Approval request - Requires manual approval from authorized personnel
- Deployment - Executes deployment with rollback capability
- Post-deployment verification - Ensures system health
Required Inputs:
version- Release version (e.g., v1.0.0)environment- Target environment (production/staging)notes- Deployment notes or changes
Environment Protection:
- Uses GitHub environments for approval gates
- Requires approval from authorized team members
- Automatic rollback on deployment failure
File: .github/workflows/security-approval.yml
Triggers:
- Manual workflow dispatch
- Requires operation type, severity, and justification
Approval Process:
- Security validation - Validates user permissions and justification
- Security approval - Requires approval from security team
- Operation execution - Performs security operation
- Reporting - Creates detailed security report
Available Operations:
security-scan- Comprehensive security scanningdependency-update- Security dependency updatesvulnerability-fix- Apply vulnerability fixesaccess-review- Conduct access and permission review
Required Inputs:
operation- Type of security operationseverity- Security severity level (critical/high/medium/low)justification- Detailed justification (min 20 characters)target-branch- Target branch for changes
Security Features:
- User authorization validation
- Automatic PR creation for security changes
- Security artifact upload and retention
- Team notification system
File: .github/workflows/database-approval.yml
Triggers:
- Manual workflow dispatch
- Requires operation type, environment, and justification
Approval Process:
- Operation validation - Validates permissions and requirements
- Database approval - Requires approval from database administrators
- Operation execution - Performs database operation with backup
- Verification - Validates database integrity
Available Operations:
migration- Database schema migrationsseed-data- Database seeding operationsbackup- Full database backupsrestore- Database restore operationsschema-update- Schema updates
Required Inputs:
operation- Type of database operationenvironment- Target environment (staging/production)backup-required- Create backup before operationdry-run- Run in dry-run mode (no changes)justification- Detailed justification (min 30 characters)
Safety Features:
- Automatic backup creation
- Dry-run mode for testing
- Production operation restrictions
- Database verification and health checks
Create the following environments in your GitHub repository:
- Name:
production - Protection Rules:
- Required reviewers: Add production deployment team
- Wait timer: 5 minutes
- Restrict deployments to specific branches: main
- Name:
staging - Protection Rules:
- Required reviewers: Add staging deployment team
- Wait timer: 2 minutes
- Name:
security-operations - Protection Rules:
- Required reviewers: Add security team members
- Wait timer: 1 minute
- Name:
database-operations - Protection Rules:
- Required reviewers: Add database administrators
- Wait timer: 2 minutes
Add these secrets to your GitHub repository:
# Database connections
DATABASE_URL_STAGING=postgresql://...
DATABASE_URL_PRODUCTION=postgresql://...
# Security scanning tools
SNYK_TOKEN=your_snyk_token
# Deployment credentials
DEPLOY_KEY=your_deployment_ssh_key
DOCKER_REGISTRY_TOKEN=your_docker_token
# Notification services
SLACK_WEBHOOK_URL=your_slack_webhook
Configure team permissions in GitHub repository settings:
- Members: Senior developers, DevOps team
- Permissions: Write access, deployment permissions
- Members: Security engineers, senior developers
- Permissions: Write access, security operations
- Members: DBAs, backend leads
- Permissions: Write access, database operations
- Navigate to Actions tab in GitHub repository
- Select "Production Deployment (Approval Required)" workflow
- Click "Run workflow"
- Fill in required inputs:
- Version:
v1.2.0 - Environment:
production - Notes:
Fixed critical security vulnerability and added logging system
- Version:
- Submit and wait for approval
- Team members will receive approval request
- Once approved, deployment executes automatically
- Go to Actions → Security Operations
- Click "Run workflow"
- Select operation type and severity:
- Operation:
vulnerability-fix - Severity:
high - Justification:
Critical CVE-2024-1234 requires immediate patching - Target branch:
main
- Operation:
- Submit for security team approval
- Security team reviews and approves
- Operation executes with automatic PR creation
- Navigate to Database Operations workflow
- Select operation and settings:
- Operation:
migration - Environment:
staging - Backup required:
true - Dry run:
true(for testing) - Justification:
Add user_preferences table for new feature
- Operation:
- Submit for DBA approval
- Database administrators review and approve
- Operation executes with backup and verification
- Production deployments automatically rollback on failure
- Database operations can be rolled back
- Security operations create revert PRs
- Database operations create automatic backups
- Artifacts retained for 30 days
- Operation logs stored for audit trail
- Multi-level approval system
- Time delays for critical operations
- User authorization validation
- Real-time operation status updates
- Automatic team notifications
- Detailed operation reports
- Always run in staging first
- Verify all tests pass
- Check security scan results
- Review code changes thoroughly
- Provide detailed justifications
- Use appropriate severity levels
- Review generated PRs carefully
- Monitor for unexpected behavior
- Always use dry-run mode first
- Create backups before changes
- Test in staging environment
- Verify data integrity post-operation
- Only approve operations you understand
- Review all provided justifications
- Check for proper documentation
- Ensure rollback plans exist
- Check environment protection rules
- Verify team member permissions
- Ensure required reviewers are added
- Review workflow logs for errors
- Check secret configuration
- Verify service connections
- Check database connection strings
- Verify permissions and access
- Review operation logs
- Check workflow logs in Actions tab
- Review environment settings in repository settings
- Verify team permissions and member access
- Consult operation reports for detailed information
Potential improvements to consider:
-
Automated Testing Integration
- Integrate with test suites
- Automated rollback on test failures
- Performance testing integration
-
Enhanced Monitoring
- Real-time operation dashboards
- Integration with monitoring tools
- Automated alerting systems
-
Advanced Security
- Multi-signature approvals
- Time-based access controls
- Automated vulnerability scanning
-
Database Enhancements
- Automated backup scheduling
- Database performance monitoring
- Multi-environment synchronization
- Never commit sensitive data to repository
- Use GitHub secrets for all credentials
- Regularly rotate access tokens and keys
- Monitor approval logs for unauthorized access
- Implement least privilege principle for team permissions
This approval system ensures that critical operations are properly reviewed, documented, and executed safely while maintaining operational efficiency.