name: 08.2. Critical Asset Monitor on: schedule: - cron: '0 0 15 2,5,8,11 *' # Mid-Quarter pulse: Feb, May, Aug, Nov 15th workflow_dispatch: permissions: contents: write pull-requests: write jobs: monitor-critical: runs-on: ubuntu-latest steps: - name: Repository Synchronization uses: actions/checkout@v7 with: ref: develop - name: Python 3.11 Environment Provisioning uses: actions/setup-python@v6 with: python-version: '3.11' cache: 'pip' - name: Dependencies Installation run: | python -m pip install --upgrade pip pip install --no-cache-dir httpx PyYAML PyGithub beautifulsoup4 tenacity - name: Critical Health Audit Execution env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PYTHONPATH: ${{ github.workspace }} PYTHONUNBUFFERED: 1 run: | python -c " import asyncio, httpx, yaml, os from datetime import datetime from src.gitops_manager import RepositoryController async def check(): with open('data/inventory.yaml', 'r') as f: inv = yaml.safe_load(f) or {} critical_links = [u for u, d in inv.items() if any(t in ['[DE FACTO STANDARD]', '[ENTERPRISE-STABLE]'] for t in d.get('tags', []))] print(f'[*] Auditing {len(critical_links)} critical assets...') dead = [] async with httpx.AsyncClient(timeout=10.0, follow_redirects=True) as client: for url in critical_links: try: resp = await client.get(url) if resp.status_code == 404: dead.append(url) print(f' [!] CRITICAL DOWN: {url}') except: pass if dead: # Flag in inventory for url in dead: inv[url]['status'] = 'offline' inv[url]['last_offline'] = datetime.now().isoformat() with open('data/inventory.yaml', 'w') as f: yaml.dump(inv, f, sort_keys=False, allow_unicode=True) with open('data/inventory.yaml', 'r') as f: updated_inv = f.read() # Create PR/Issue git = RepositoryController(os.environ['GH_TOKEN'], 'nubenetes/awesome-kubernetes') body = '### 🚨 Critical Assets Offline\n\n' + '\n'.join([f'- {u}' for u in dead]) git.apply_multi_file_changes({'data/inventory.yaml': updated_inv}, {'removals': len(dead)}) print('[OK] Inventory updated and PR created.') else: print('[OK] All critical assets are online.') asyncio.run(check()) "