Skip to content
Latchkey

How to Set Billing Alerts and Budgets for CI

A spending limit and a budget alert turn a silent cost blowout into an early warning instead of a month-end surprise.

Set an Actions spending limit in billing settings, add budget alerts at percentage thresholds, and back them with an automated check on the billing API.

Steps

  • Set an Actions and Packages spending limit in Billing settings.
  • Create budget alerts at, say, 50%, 80%, and 100% of the budget.
  • Add a scheduled job that queries the billing API and posts to Slack near the threshold.

Alert when usage nears budget

Terminal
# Scheduled check: fail (and notify) if minutes exceed a threshold
USED=$(curl -sS -H "Authorization: Bearer $GH_TOKEN" \
  "https://api.github.com/orgs/my-org/settings/billing/actions" \
  | jq '.total_minutes_used')
if [ "$USED" -gt 35000 ]; then
  echo "Actions minutes at $USED, over budget threshold"
  exit 1
fi

Gotchas

  • A spending limit of zero blocks all paid minutes, which can halt private-repo CI unexpectedly.
  • Alerts are informational; only the hard spending limit actually stops spend.
  • The classic Actions billing endpoint reports included and paid minutes separately.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →