From fb88440ec4c064dc052ac9927dfdc44b5d54b89b Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Fri, 12 Jun 2026 23:24:18 +0000 Subject: [PATCH] ci-pipeline-health: billing moved to the enhanced usage endpoint The legacy /settings/billing/actions endpoint now returns 410; sum Minutes usageItems from /settings/billing/usage instead (found during the infra#16 retro: June-to-date = 420/2000). Co-Authored-By: Claude Fable 5 --- stacks/ci-pipeline-health/files/sweep.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/stacks/ci-pipeline-health/files/sweep.sh b/stacks/ci-pipeline-health/files/sweep.sh index 6f3af29c..beba2315 100644 --- a/stacks/ci-pipeline-health/files/sweep.sh +++ b/stacks/ci-pipeline-health/files/sweep.sh @@ -63,16 +63,15 @@ done wp_checked=$(awk '{s+=$1} END {print s+0}' "$NOTES.wpcount" 2>/dev/null || echo 0) rm -f "$NOTES.wpcount" -# --- 3) GHA minutes vs free tier --- -billing=$(gh_get "${GH_API}/users/ViktorBarzin/settings/billing/actions") +# --- 3) GHA minutes vs free tier (enhanced billing API; old endpoint is 410-gone) --- +YM_Y=$(date -u +%Y); YM_M=$(date -u +%-m) +billing=$(gh_get "${GH_API}/users/ViktorBarzin/settings/billing/usage?year=${YM_Y}&month=${YM_M}") if [ $? -eq 0 ]; then - used=$(printf '%s' "$billing" | jq -r '.total_minutes_used') - included=$(printf '%s' "$billing" | jq -r '.included_minutes') - if [ "${included:-0}" -gt 0 ] 2>/dev/null; then - pct=$((used * 100 / included)) - echo "GHA minutes: ${used}/${included} (${pct}%)" >>"$NOTES" - [ "$pct" -ge 75 ] && echo "GHA minutes at ${pct}% of the free tier (${used}/${included}) — check for runaway workflows or consider Pro" >>"$ISSUES" - fi + used=$(printf '%s' "$billing" | jq '[.usageItems[] | select(.product=="actions" and .unitType=="Minutes") | .quantity] | add // 0 | floor') + included=2000 + pct=$((used * 100 / included)) + echo "GHA minutes (month): ${used}/${included} (${pct}%)" >>"$NOTES" + [ "$pct" -ge 75 ] && echo "GHA minutes at ${pct}% of the free tier (${used}/${included}) — check for runaway workflows or consider Pro" >>"$ISSUES" else echo "minutes check unavailable" >>"$NOTES" fi