# Workflow Automation Builder

> This skill should be used when the user asks to "automate workflows", "create CI/CD pipelines", "automate deployments", "setup GitHub Actions", "optimize build processes", "automate testing", or needs comprehensive workflow automation and process optimization. Use when this capability is needed.

- Skill: `tomevault-io/workflow-automation-builder` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/workflow-automation-builder`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/workflow-automation-builder/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/workflow-automation-builder

---


# Workflow Automation Builder: Time-Saving CI/CD & Process Automation

## Overview

The Workflow Automation Builder creates intelligent automation workflows that reduce manual overhead by 50-70%. It generates optimized CI/CD pipelines, automates repetitive tasks, and creates self-maintaining development workflows.

## Core Automation Areas

### 1. Intelligent CI/CD Pipeline Generation

**Smart Pipeline Analysis:**
```python
import yaml
import os
from pathlib import Path
from typing import Dict, List, Any

class CICDPipelineGenerator:
    def __init__(self, project_path: str):
        self.project_path = Path(project_path)
        self.detected_technologies = self._detect_technologies()
        self.deployment_targets = self._detect_deployment_targets()

    def _detect_technologies(self) -> Dict[str, bool]:
        """Automatically detect project technologies"""
        technologies = {
            'python': (self.project_path / 'requirements.txt').exists() or
                     (self.project_path / 'pyproject.toml').exists(),
            'nodejs': (self.project_path / 'package.json').exists(),
            'typescript': (self.project_path / 'tsconfig.json').exists(),
            'docker': (self.project_path / 'Dockerfile').exists(),
            'streamlit': self._check_file_content('requirements.txt', 'streamlit'),
            'fastapi': self._check_file_content('requirements.txt', 'fastapi'),
            'react': self._check_file_content('package.json', 'react'),
            'nextjs': (self.project_path / 'next.config.js').exists()
        }
        return {k: v for k, v in technologies.items() if v}

    def _detect_deployment_targets(self) -> List[str]:
        """Detect deployment configurations"""
        targets = []
        if (self.project_path / 'railway.json').exists():
            targets.append('railway')
        if (self.project_path / 'vercel.json').exists():
            targets.append('vercel')
        if (self.project_path / 'render.yaml').exists():
            targets.append('render')
        if (self.project_path / 'fly.toml').exists():
            targets.append('fly')
        return targets

    def _check_file_content(self, filename: str, search_term: str) -> bool:
        """Check if file contains specific term"""
        file_path = self.project_path / filename
        if file_path.exists():
            try:
                content = file_path.read_text()
                return search_term in content.lower()
            except:
                return False
        return False

    def generate_optimized_pipeline(self) -> Dict[str, Any]:
        """Generate optimized CI/CD pipeline based on detected technologies"""
        pipeline = {
            'name': 'Automated CI/CD Pipeline',
            'on': {
                'push': {'branches': ['main', 'develop']},
                'pull_request': {'branches': ['main']},
                'schedule': [{'cron': '0 2 * * 0'}]  # Weekly security scan
            },
            'jobs': {}
        }

        # Add jobs based on detected technologies
        if self.detected_technologies.get('python'):
            pipeline['jobs'].update(self._generate_python_jobs())

        if self.detected_technologies.get('nodejs') or self.detected_technologies.get('typescript'):
            pipeline['jobs'].update(self._generate_nodejs_jobs())

        # Add deployment jobs
        if self.deployment_targets:
            pipeline['jobs'].update(self._generate_deployment_jobs())

        # Add security and quality jobs
        pipeline['jobs'].update(self._generate_security_jobs())

        return pipeline

    def _generate_python_jobs(self) -> Dict[str, Any]:
        """Generate Python-specific CI/CD jobs"""
        return {
            'python-quality': {
                'name': 'Python Code Quality & Testing',
                'runs-on': 'ubuntu-latest',
                'strategy': {
                    'matrix': {
                        'python-version': ['3.10', '3.11', '3.12']
                    }
                },
                'steps': [
                    {'uses': 'actions/checkout@v4'},
                    {
                        'name': 'Set up Python ${{ matrix.python-version }}',
                        'uses': 'actions/setup-python@v4',
                        'with': {'python-version': '${{ matrix.python-version }}'}
                    },
                    {
                        'name': 'Cache pip dependencies',
                        'uses': 'actions/cache@v3',
                        'with': {
                            'path': '~/.cache/pip',
                            'key': '${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}',
                            'restore-keys': '${{ runner.os }}-pip-'
                        }
                    },
                    {
                        'name': 'Install dependencies',
                        'run': 'pip install -r requirements.txt && pip install pytest black isort flake8 bandit safety'
                    },
                    {
                        'name': 'Code formatting check (Black)',
                        'run': 'black --check .',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Import sorting check (isort)',
                        'run': 'isort --check-only .',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Linting (flake8)',
                        'run': 'flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics'
                    },
                    {
                        'name': 'Security check (Bandit)',
                        'run': 'bandit -r . -f json -o bandit-report.json',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Dependency vulnerability check',
                        'run': 'safety check',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Run tests with coverage',
                        'run': 'pytest --cov=. --cov-report=xml --cov-report=term-missing'
                    },
                    {
                        'name': 'Upload coverage to Codecov',
                        'uses': 'codecov/codecov-action@v3',
                        'with': {
                            'file': './coverage.xml',
                            'fail_ci_if_error': False
                        }
                    }
                ]
            }
        }

    def _generate_nodejs_jobs(self) -> Dict[str, Any]:
        """Generate Node.js/TypeScript-specific CI/CD jobs"""
        return {
            'nodejs-quality': {
                'name': 'Node.js Code Quality & Testing',
                'runs-on': 'ubuntu-latest',
                'strategy': {
                    'matrix': {
                        'node-version': ['18.x', '20.x', '21.x']
                    }
                },
                'steps': [
                    {'uses': 'actions/checkout@v4'},
                    {
                        'name': 'Use Node.js ${{ matrix.node-version }}',
                        'uses': 'actions/setup-node@v3',
                        'with': {
                            'node-version': '${{ matrix.node-version }}',
                            'cache': 'npm'
                        }
                    },
                    {
                        'name': 'Install dependencies',
                        'run': 'npm ci'
                    },
                    {
                        'name': 'Type checking',
                        'run': 'npm run type-check',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Linting',
                        'run': 'npm run lint',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Format check',
                        'run': 'npm run format:check',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Security audit',
                        'run': 'npm audit --audit-level high',
                        'continue-on-error': True
                    },
                    {
                        'name': 'Run tests',
                        'run': 'npm test -- --coverage'
                    },
                    {
                        'name': 'Build project',
                        'run': 'npm run build'
                    }
                ]
            }
        }

    def _generate_deployment_jobs(self) -> Dict[str, Any]:
        """Generate deployment jobs based on detected targets"""
        jobs = {}

        if 'railway' in self.deployment_targets:
            jobs['deploy-railway'] = {
                'name': 'Deploy to Railway',
                'runs-on': 'ubuntu-latest',
                'needs': ['python-quality'] if 'python' in self.detected_technologies else ['nodejs-quality'],
                'if': 'github.ref == 'refs/heads/main' && github.event_name == 'push'',
                'steps': [
                    {'uses': 'actions/checkout@v4'},
                    {
                        'name': 'Deploy to Railway',
                        'uses': 'railwayapp/railway-deploy@v2',
                        'with': {
                            'railway-token': '${{ secrets.RAILWAY_TOKEN }}',
                            'service': 'production'
                        }
                    }
                ]
            }

        if 'vercel' in self.deployment_targets:
            jobs['deploy-vercel'] = {
                'name': 'Deploy to Vercel',
                'runs-on': 'ubuntu-latest',
                'needs': ['nodejs-quality'],
                'if': 'github.ref == 'refs/heads/main' && github.event_name == 'push'',
                'steps': [
                    {'uses': 'actions/checkout@v4'},
                    {
                        'name': 'Deploy to Vercel',
                        'uses': 'amondnet/vercel-action@v20',
                        'with': {
                            'vercel-token': '${{ secrets.VERCEL_TOKEN }}',
                            'vercel-org-id': '${{ secrets.ORG_ID }}',
                            'vercel-project-id': '${{ secrets.PROJECT_ID }}',
                            'vercel-args': '--prod'
                        }
                    }
                ]
            }

        return jobs

    def _generate_security_jobs(self) -> Dict[str, Any]:
        """Generate security and monitoring jobs"""
        return {
            'security-scan': {
                'name': 'Security Scanning',
                'runs-on': 'ubuntu-latest',
                'if': 'github.event_name == 'schedule' || contains(github.event.head_commit.message, '[security]')',
                'steps': [
                    {'uses': 'actions/checkout@v4'},
                    {
                        'name': 'Run Trivy vulnerability scanner',
                        'uses': 'aquasecurity/trivy-action@master',
                        'with': {
                            'scan-type': 'fs',
                            'scan-ref': '.',
                            'format': 'sarif',
                            'output': 'trivy-results.sarif'
                        }
                    },
                    {
                        'name': 'Upload Trivy scan results to GitHub Security tab',
                        'uses': 'github/codeql-action/upload-sarif@v2',
                        'if': 'always()',
                        'with': {'sarif_file': 'trivy-results.sarif'}
                    }
                ]
            }
        }
```

### 2. Automated Testing Workflows

**Smart Test Automation:**
```python
class TestAutomationBuilder:
    def __init__(self, project_path: str):
        self.project_path = Path(project_path)

    def generate_test_automation(self) -> Dict[str, Any]:
        """Generate comprehensive test automation workflow"""
        return {
            'name': 'Automated Testing Suite',
            'on': {
                'push': {'branches': ['**']},
                'pull_request': {'branches': ['main', 'develop']},
                'schedule': [{'cron': '0 6 * * 1-5'}]  # Weekday morning tests
            },
            'jobs': {
                'test-matrix': self._generate_test_matrix(),
                'integration-tests': self._generate_integration_tests(),
                'performance-tests': self._generate_performance_tests(),
                'security-tests': self._generate_security_tests()
            }
        }

    def _generate_test_matrix(self) -> Dict[str, Any]:
        """Generate matrix testing across multiple environments"""
        return {
            'name': 'Matrix Testing',
            'runs-on': 'ubuntu-latest',
            'strategy': {
                'matrix': {
                    'python-version': ['3.10', '3.11', '3.12'],
                    'dependency-version': ['latest', 'minimum'],
                    'include': [
                        {
                            'python-version': '3.10',
                            'dependency-version': 'latest',
                            'coverage': True
                        }
                    ]
                }
            },
            'steps': [
                {'uses': 'actions/checkout@v4'},
                {
                    'name': 'Set up Python ${{ matrix.python-version }}',
                    'uses': 'actions/setup-python@v4',
                    'with': {'python-version': '${{ matrix.python-version }}'}
                },
                {
                    'name': 'Install dependencies',
                    'run': '''
                        if [ "${{ matrix.dependency-version }}" == "minimum" ]; then
                            pip install -r requirements-min.txt
                        else
                            pip install -r requirements.txt
                        fi
                        pip install pytest pytest-cov pytest-xdist pytest-benchmark
                    '''
                },
                {
                    'name': 'Run tests with coverage',
                    'run': 'pytest -n auto --cov=. --cov-report=xml --benchmark-skip',
                    'if': 'matrix.coverage'
                },
                {
                    'name': 'Run tests without coverage',
                    'run': 'pytest -n auto --benchmark-skip',
                    'if': '!matrix.coverage'
                }
            ]
        }

    def _generate_integration_tests(self) -> Dict[str, Any]:
        """Generate integration test workflow"""
        return {
            'name': 'Integration Tests',
            'runs-on': 'ubuntu-latest',
            'needs': ['test-matrix'],
            'services': {
                'postgres': {
                    'image': 'postgres:15',
                    'env': {
                        'POSTGRES_PASSWORD': 'postgres',
                        'POSTGRES_DB': 'test_db'
                    },
                    'options': '--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5'
                },
                'redis': {
                    'image': 'redis:7',
                    'options': '--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5'
                }
            },
            'steps': [
                {'uses': 'actions/checkout@v4'},
                {
                    'name': 'Set up Python',
                    'uses': 'actions/setup-python@v4',
                    'with': {'python-version': '3.11'}
                },
                {
                    'name': 'Install dependencies',
                    'run': 'pip install -r requirements.txt'
                },
                {
                    'name': 'Run integration tests',
                    'run': 'pytest tests/integration/ -v --tb=short',
                    'env': {
                        'DATABASE_URL': 'postgresql://postgres:postgres@localhost:5432/test_db',
                        'REDIS_URL': 'redis://localhost:6379/0'
                    }
                }
            ]
        }

    def _generate_performance_tests(self) -> Dict[str, Any]:
        """Generate performance testing workflow"""
        return {
            'name': 'Performance Tests',
            'runs-on': 'ubuntu-latest',
            'if': 'github.event_name == 'schedule' || contains(github.event.head_commit.message, '[perf]')',
            'steps': [
                {'uses': 'actions/checkout@v4'},
                {
                    'name': 'Set up Python',
                    'uses': 'actions/setup-python@v4',
                    'with': {'python-version': '3.11'}
                },
                {
                    'name': 'Install dependencies',
                    'run': 'pip install -r requirements.txt pytest-benchmark locust'
                },
                {
                    'name': 'Run benchmark tests',
                    'run': 'pytest tests/benchmark/ --benchmark-only --benchmark-json=benchmark.json'
                },
                {
                    'name': 'Run load tests',
                    'run': 'locust -f tests/load/locustfile.py --headless --users 50 --spawn-rate 5 --run-time 60s --host http://localhost:8501'
                },
                {
                    'name': 'Upload benchmark results',
                    'uses': 'actions/upload-artifact@v3',
                    'with': {
                        'name': 'benchmark-results',
                        'path': 'benchmark.json'
                    }
                }
            ]
        }
```

### 3. Deployment Automation

**Zero-Downtime Deployment:**
```python
class DeploymentAutomationBuilder:
    def __init__(self):
        self.deployment_strategies = {
            'railway': self._railway_deployment,
            'vercel': self._vercel_deployment,
            'docker': self._docker_deployment
        }

    def generate_deployment_workflow(self, platform: str) -> Dict[str, Any]:
        """Generate platform-specific deployment workflow"""
        if platform in self.deployment_strategies:
            return self.deployment_strategies[platform]()
        else:
            raise ValueError(f"Unsupported platform: {platform}")

    def _railway_deployment(self) -> Dict[str, Any]:
        """Generate Railway deployment with health checks"""
        return {
            'name': 'Railway Deployment',
            'on': {
                'push': {'branches': ['main']},
                'workflow_dispatch': None
            },
            'jobs': {
                'deploy': {
                    'name': 'Deploy to Railway',
                    'runs-on': 'ubuntu-latest',
                    'steps': [
                        {'uses': 'actions/checkout@v4'},
                        {
                            'name': 'Deploy to Railway',
                            'uses': 'railwayapp/railway-deploy@v2',
                            'with': {
                                'railway-token': '${{ secrets.RAILWAY_TOKEN }}',
                                'service': '${{ github.ref_name == 'main' && 'production' || 'staging' }}'
                            }
                        },
                        {
                            'name': 'Health Check',
                            'run': '''
                                echo "Waiting for deployment to be ready..."
                                sleep 30

                                for i in {1..10}; do
                                    if curl -f $HEALTH_CHECK_URL; then
                                        echo "Deployment successful!"
                                        exit 0
                                    fi
                                    echo "Attempt $i failed, retrying in 10s..."
                                    sleep 10
                                done

                                echo "Deployment health check failed"
                                exit 1
                            ''',
                            'env': {
                                'HEALTH_CHECK_URL': '${{ secrets.RAILWAY_HEALTH_URL }}'
                            }
                        },
                        {
                            'name': 'Rollback on failure',
                            'if': 'failure()',
                            'run': '''
                                echo "Deployment failed, initiating rollback..."
                                # Add rollback logic here
                            '''
                        }
                    ]
                }
            }
        }

    def _vercel_deployment(self) -> Dict[str, Any]:
        """Generate Vercel deployment with preview environments"""
        return {
            'name': 'Vercel Deployment',
            'on': {
                'push': {'branches': ['main', 'develop']},
                'pull_request': {'branches': ['main']},
                'workflow_dispatch': None
            },
            'jobs': {
                'deploy': {
                    'name': 'Deploy to Vercel',
                    'runs-on': 'ubuntu-latest',
                    'outputs': {
                        'preview-url': '${{ steps.vercel.outputs.preview-url }}'
                    },
                    'steps': [
                        {'uses': 'actions/checkout@v4'},
                        {
                            'name': 'Install Node.js',
                            'uses': 'actions/setup-node@v3',
                            'with': {
                                'node-version': '18',
                                'cache': 'npm'
                            }
                        },
                        {
                            'name': 'Install dependencies',
                            'run': 'npm ci'
                        },
                        {
                            'name': 'Build project',
                            'run': 'npm run build'
                        },
                        {
                            'id': 'vercel',
                            'name': 'Deploy to Vercel',
                            'uses': 'amondnet/vercel-action@v20',
                            'with': {
                                'vercel-token': '${{ secrets.VERCEL_TOKEN }}',
                                'vercel-org-id': '${{ secrets.ORG_ID }}',
                                'vercel-project-id': '${{ secrets.PROJECT_ID }}',
                                'vercel-args': '${{ github.ref_name == 'main' && '--prod' || '' }}'
                            }
                        }
                    ]
                },
                'test-deployment': {
                    'name': 'Test Deployment',
                    'runs-on': 'ubuntu-latest',
                    'needs': ['deploy'],
                    'steps': [
                        {
                            'name': 'Test deployment URL',
                            'run': '''
                                URL="${{ needs.deploy.outputs.preview-url }}"
                                echo "Testing deployment at: $URL"

                                # Basic health check
                                if curl -f "$URL"; then
                                    echo "Deployment is accessible"
                                else
                                    echo "Deployment failed health check"
                                    exit 1
                                fi

                                # Performance check
                                RESPONSE_TIME=$(curl -o /dev/null -s -w '%{time_total}' "$URL")
                                echo "Response time: ${RESPONSE_TIME}s"

                                if (( $(echo "$RESPONSE_TIME > 3.0" | bc -l) )); then
                                    echo "Warning: Response time > 3s"
                                fi
                            '''
                        }
                    ]
                }
            }
        }
```

### 4. Automated Monitoring & Alerting

**Intelligent Monitoring Setup:**
```python
class MonitoringAutomationBuilder:
    def __init__(self):
        self.monitoring_configs = {}

    def generate_monitoring_workflow(self) -> Dict[str, Any]:
        """Generate automated monitoring and alerting workflow"""
        return {
            'name': 'Automated Monitoring',
            'on': {
                'schedule': [
                    {'cron': '*/15 * * * *'},  # Every 15 minutes
                    {'cron': '0 9 * * MON'}    # Weekly summary
                ],
                'workflow_dispatch': None
            },
            'jobs': {
                'health-check': self._generate_health_check_job(),
                'performance-monitoring': self._generate_performance_monitoring_job(),
                'cost-monitoring': self._generate_cost_monitoring_job(),
                'security-monitoring': self._generate_security_monitoring_job()
            }
        }

    def _generate_health_check_job(self) -> Dict[str, Any]:
        """Generate comprehensive health check job"""
        return {
            'name': 'Health Check Monitoring',
            'runs-on': 'ubuntu-latest',
            'steps': [
                {
                    'name': 'Check Application Health',
                    'run': '''
                        # Check main application
                        if ! curl -f ${{ secrets.APP_URL }}/_health; then
                            echo "❌ Application health check failed"
                            echo "HEALTH_STATUS=FAILED" >> $GITHUB_ENV
                        else
                            echo "✅ Application health check passed"
                            echo "HEALTH_STATUS=PASSED" >> $GITHUB_ENV
                        fi

                        # Check database connectivity
                        if ! curl -f ${{ secrets.APP_URL }}/_health/db; then
                            echo "❌ Database health check failed"
                            echo "DB_STATUS=FAILED" >> $GITHUB_ENV
                        else
                            echo "✅ Database health check passed"
                            echo "DB_STATUS=PASSED" >> $GITHUB_ENV
                        fi

                        # Check external API dependencies
                        if ! curl -f ${{ secrets.APP_URL }}/_health/external; then
                            echo "⚠️ External API health check failed"
                            echo "EXTERNAL_STATUS=FAILED" >> $GITHUB_ENV
                        else
                            echo "✅ External API health check passed"
                            echo "EXTERNAL_STATUS=PASSED" >> $GITHUB_ENV
                        fi
                    '''
                },
                {
                    'name': 'Send Slack Alert on Failure',
                    'if': 'env.HEALTH_STATUS == 'FAILED' || env.DB_STATUS == 'FAILED'',
                    'uses': '8398a7/action-slack@v3',
                    'with': {
                        'status': 'failure',
                        'text': '🚨 Critical system failure detected!\nHealth: ${{ env.HEALTH_STATUS }}\nDB: ${{ env.DB_STATUS }}',
                        'webhook_url': '${{ secrets.SLACK_WEBHOOK }}'
                    }
                }
            ]
        }

    def _generate_performance_monitoring_job(self) -> Dict[str, Any]:
        """Generate performance monitoring job"""
        return {
            'name': 'Performance Monitoring',
            'runs-on': 'ubuntu-latest',
            'if': 'github.event.schedule == '*/15 * * * *'',
            'steps': [
                {
                    'name': 'Performance Check',
                    'run': '''
                        # Measure response times
                        RESPONSE_TIME=$(curl -o /dev/null -s -w '%{time_total}' ${{ secrets.APP_URL }})
                        TTFB=$(curl -o /dev/null -s -w '%{time_starttransfer}' ${{ secrets.APP_URL }})

                        echo "Response Time: ${RESPONSE_TIME}s"
                        echo "Time to First Byte: ${TTFB}s"

                        # Check if performance is degraded
                        if (( $(echo "$RESPONSE_TIME > 5.0" | bc -l) )); then
                            echo "⚠️ Performance degradation detected"
                            echo "PERF_ALERT=true" >> $GITHUB_ENV
                            echo "RESPONSE_TIME=$RESPONSE_TIME" >> $GITHUB_ENV
                        fi

                        # Store metrics for trending
                        echo "$(date '+%Y-%m-%d %H:%M:%S'),$RESPONSE_TIME,$TTFB" >> performance_metrics.csv
                    '''
                },
                {
                    'name': 'Upload Performance Metrics',
                    'uses': 'actions/upload-artifact@v3',
                    'with': {
                        'name': 'performance-metrics',
                        'path': 'performance_metrics.csv'
                    }
                },
                {
                    'name': 'Performance Alert',
                    'if': 'env.PERF_ALERT == 'true'',
                    'uses': '8398a7/action-slack@v3',
                    'with': {
                        'status': 'warning',
                        'text': '🐌 Performance degradation detected!\nResponse Time: ${{ env.RESPONSE_TIME }}s (threshold: 5s)',
                        'webhook_url': '${{ secrets.SLACK_WEBHOOK }}'
                    }
                }
            ]
        }

    def _generate_cost_monitoring_job(self) -> Dict[str, Any]:
        """Generate cost monitoring job"""
        return {
            'name': 'Cost Monitoring',
            'runs-on': 'ubuntu-latest',
            'if': 'github.event.schedule == '0 9 * * MON'',
            'steps': [
                {
                    'name': 'Monitor Infrastructure Costs',
                    'run': '''
                        # Fetch Railway costs (example)
                        RAILWAY_USAGE=$(curl -H "Authorization: Bearer ${{ secrets.RAILWAY_API_TOKEN }}" \
                            "https://backboard.railway.app/graphql" \
                            -d '{"query": "{ me { projects { name usage { current } } } }"}')

                        echo "Railway Usage: $RAILWAY_USAGE"

                        # Fetch Vercel costs (example)
                        VERCEL_USAGE=$(curl -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \
                            "https://api.vercel.com/v1/teams/usage")

                        echo "Vercel Usage: $VERCEL_USAGE"

                        # Calculate total monthly costs
                        # This would parse the JSON responses and calculate costs
                        python3 - << 'EOF'
                        import json
                        import os

                        # Parse usage data and calculate costs
                        # Send alert if costs exceed threshold
                        monthly_threshold = float(os.environ.get('MONTHLY_COST_THRESHOLD', '100'))
                        current_cost = 75  # Example calculation

                        if current_cost > monthly_threshold * 0.8:
                            print(f"COST_ALERT=true")
                            print(f"CURRENT_COST={current_cost}")
                            with open(os.environ['GITHUB_ENV'], 'a') as f:
                                f.write(f"COST_ALERT=true\\n")
                                f.write(f"CURRENT_COST={current_cost}\\n")
                        EOF
                    ''',
                    'env': {
                        'MONTHLY_COST_THRESHOLD': '100'
                    }
                },
                {
                    'name': 'Cost Alert',
                    'if': 'env.COST_ALERT == 'true'',
                    'uses': '8398a7/action-slack@v3',
                    'with': {
                        'status': 'warning',
                        'text': '💰 Cost threshold alert!\nCurrent monthly cost: ${{ env.CURRENT_COST }}\nThreshold: $100',
                        'webhook_url': '${{ secrets.SLACK_WEBHOOK }}'
                    }
                }
            ]
        }
```

### 5. Automated Code Quality & Security

**Continuous Quality Enforcement:**
```python
class QualityAutomationBuilder:
    def generate_quality_workflow(self) -> Dict[str, Any]:
        """Generate automated code quality workflow"""
        return {
            'name': 'Automated Quality Assurance',
            'on': {
                'pull_request': {'branches': ['main', 'develop']},
                'push': {'branches': ['main']},
                'schedule': [{'cron': '0 3 * * 2,5'}]  # Tue & Fri at 3 AM
            },
            'jobs': {
                'code-quality': {
                    'name': 'Code Quality Analysis',
                    'runs-on': 'ubuntu-latest',
                    'steps': [
                        {'uses': 'actions/checkout@v4'},
                        {
                            'name': 'Set up Python',
                            'uses': 'actions/setup-python@v4',
                            'with': {'python-version': '3.11'}
                        },
                        {
                            'name': 'Install quality tools',
                            'run': '''
                                pip install black isort flake8 bandit safety mypy pylint
                                pip install radon xenon complexity-report
                                pip install -r requirements.txt
                            '''
                        },
                        {
                            'name': 'Code Formatting Analysis',
                            'run': '''
                                echo "## Code Formatting Report" >> quality_report.md
                                echo "### Black (Code Formatting)" >> quality_report.md
                                if black --check . --diff; then
                                    echo "✅ Code formatting is correct" >> quality_report.md
                                else
                                    echo "❌ Code formatting issues found" >> quality_report.md
                                    echo "FORMATTING_ISSUES=true" >> $GITHUB_ENV
                                fi

                                echo "### isort (Import Sorting)" >> quality_report.md
                                if isort --check-only . --diff; then
                                    echo "✅ Import sorting is correct" >> quality_report.md
                                else
                                    echo "❌ Import sorting issues found" >> quality_report.md
                                    echo "IMPORT_ISSUES=true" >> $GITHUB_ENV
                                fi
                            '''
                        },
                        {
                            'name': 'Code Complexity Analysis',
                            'run': '''
                                echo "### Code Complexity Analysis" >> quality_report.md

                                # Cyclomatic complexity
                                radon cc . -s --total-average >> complexity_report.txt
                                COMPLEXITY_SCORE=$(radon cc . -s --total-average | tail -1 | awk '{print $NF}' | tr -d '()')
                                echo "Average Complexity: $COMPLEXITY_SCORE" >> quality_report.md

                                # Maintainability index
                                radon mi . -s >> maintainability_report.txt

                                # Check for high complexity functions
                                HIGH_COMPLEXITY=$(radon cc . --min C)
                                if [ ! -z "$HIGH_COMPLEXITY" ]; then
                                    echo "⚠️ High complexity functions found:" >> quality_report.md
                                    echo "$HIGH_COMPLEXITY" >> quality_report.md
                                    echo "COMPLEXITY_ISSUES=true" >> $GITHUB_ENV
                                fi
                            '''
                        },
                        {
                            'name': 'Security Analysis',
                            'run': '''
                                echo "### Security Analysis" >> quality_report.md

                                # Bandit security check
                                bandit -r . -f json -o bandit_report.json || true
                                if [ -f bandit_report.json ]; then
                                    SECURITY_ISSUES=$(cat bandit_report.json | jq '.results | length')
                                    echo "Security issues found: $SECURITY_ISSUES" >> quality_report.md

                                    if [ "$SECURITY_ISSUES" -gt "0" ]; then
                                        echo "SECURITY_ISSUES=true" >> $GITHUB_ENV
                                        echo "SECURITY_COUNT=$SECURITY_ISSUES" >> $GITHUB_ENV
                                    fi
                                fi

                                # Dependency vulnerability check
                                safety check --json --output safety_report.json || true
                                if [ -f safety_report.json ]; then
                                    VULN_COUNT=$(cat safety_report.json | jq '. | length')
                                    echo "Vulnerable dependencies: $VULN_COUNT" >> quality_report.md

                                    if [ "$VULN_COUNT" -gt "0" ]; then
                                        echo "DEPENDENCY_VULNS=true" >> $GITHUB_ENV
                                        echo "VULN_COUNT=$VULN_COUNT" >> $GITHUB_ENV
                                    fi
                                fi
                            '''
                        },
                        {
                            'name': 'Type Checking',
                            'run': '''
                                echo "### Type Checking (mypy)" >> quality_report.md
                                if mypy . --ignore-missing-imports --strict-optional; then
                                    echo "✅ Type checking passed" >> quality_report.md
                                else
                                    echo "❌ Type checking issues found" >> quality_report.md
                                    echo "TYPE_ISSUES=true" >> $GITHUB_ENV
                                fi
                            '''
                        },
                        {
                            'name': 'Generate Quality Score',
                            'run': '''
                                python3 - << 'EOF'
                                import os

                                # Calculate quality score based on issues found
                                score = 100

                                if os.environ.get('FORMATTING_ISSUES') == 'true':
                                    score -= 10
                                if os.environ.get('IMPORT_ISSUES') == 'true':
                                    score -= 5
                                if os.environ.get('COMPLEXITY_ISSUES') == 'true':
                                    score -= 15
                                if os.environ.get('SECURITY_ISSUES') == 'true':
                                    security_count = int(os.environ.

…(truncated)
