feat(ci): add reusable actions budget guard workflow#4
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces a GitHub Actions budget guard system that monitors organizational GitHub Actions usage against configured spending caps. It includes a Bash script for usage evaluation, a test suite with multiple scenarios, two GitHub Actions workflows (one reusable, one for testing), and documentation updates to reflect the new capabilities. Changes
Sequence DiagramsequenceDiagram
participant WF as GitHub Actions Workflow
participant Script as Budget Guard Script
participant API as GitHub Billing API
participant Output as Workflow Outputs
WF->>WF: Resolve workflow source & checkout
WF->>Script: Execute with ORG, MONTHLY_CAP_MINUTES, token
alt Mock Data Available
Script->>Script: Load usage from mock JSON file
else API Failure Forced
Script->>Script: Simulate API error
else Live Query
Script->>API: GET /orgs/{org}/billing/actions<br/>(with GitHub token)
API-->>Script: Usage JSON payload
end
Script->>Script: Parse JSON, extract current month minutes
Script->>Script: Compute usage_pct, warn_mode, degrade_mode
Script->>Output: Emit structured outputs<br/>(usage_pct, warn_mode, degrade_mode, summary)
WF->>WF: Append summary to job summary
Output-->>WF: Return outputs to caller
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
usage_pct,warn_mode,degrade_mode, andsummaryoutputs70/85and fail-open when billing lookup failsValidation
bash -n .github/scripts/actions-budget-guard.sh.github/scripts/tests/actions-budget-guard.test.shSummary by CodeRabbit
Release Notes
New Features
Tests
Documentation