Chaffbroom Tollbook
GitHub gives no per-PR billing data, so Chaffbroom Tollbook rebuilds the cost from the Actions API. It posts a sticky PR comment, writes a weekly repo summary (top 5 most expensive workflows, rerun waste in dollars) and can fail a PR that goes over a budget. It is a library, a CLI and a GitHub Action.
Works withGitHub ActionsGitHub
What it does
What it catches
- Cost per PR from every job of every attempt, billed at ceil(minutes) times the rate for the runner label.
- Rerun waste: executions that a later attempt of the same run redid.
- Cancelled waste, for example runs cancelled by concurrency cancel-in-progress.
- Failed jobs are counted as useful signal, not waste.
- Cache entries and their size for the PR. The API exposes no cache hits or misses, and the comment says so.
- Weekly per-repo summary: the most expensive workflows and the rerun waste, as a job summary and optionally an issue.
- An optional budget gate that fails the PR check when the cost goes over.
- With net: true, an estimated net cost next to the list price, from your billing usage report.
Install
on:
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
cost:
needs: [test]
if: always()
runs-on: ubuntu-slim
permissions:
actions: read
pull-requests: write
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: chaffbroom/tollbook@v0
with:
mode: pr
budget: "5.00" # omit to report without gatingon:
schedule:
- cron: "0 7 * * 1"
workflow_dispatch:
permissions:
actions: read
contents: read
issues: write
jobs:
summary:
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: chaffbroom/tollbook@v0
with:
mode: weekly
days: "7"
top: "5"
issue: "true"npx chaffbroom init # shows the files it would write, writes nothing
npx chaffbroom init --yes # writes the config and the workflowsnpx chaffbroom tollbook pr --pr 123 # text summary
npx chaffbroom tollbook pr --pr 123 --comment # create or update the sticky comment
npx chaffbroom tollbook pr --pr 123 --budget 5 # exit 1 if over $5
npx chaffbroom tollbook weekly --top 5 --issue # weekly summary, also as an issue
npx chaffbroom tollbook billing --org my-org # GitHub's per-repo Actions spend this month
npx chaffbroom tollbook prices # the price table, with its source and dateStep by step, with what to check after each part: installation manual. Everything else: the README.
Permissions
- PR comment and budget gate: the cost job needs actions: read and pull-requests: write.
- Weekly summary: actions: read and contents: read; posting the optional issue needs issues: write.
- Net estimate (net: true): an org owner or billing manager token. GITHUB_TOKEN cannot read billing.
- The billing command (per-repo spend) needs an org admin or billing token.
- Without billing access the comment says Net cost unavailable and carries on with list price.
- On fork PRs the token is read-only: posting the comment becomes a warning, and the budget gate still decides the exit code.
Privacy
- The PR comment, budget gate and per-repo weekly summary run on your runner with your token and send nothing anywhere.
- Workflow names, job names and runner labels are escaped in the comment, job summary and weekly issue: no HTML, no Markdown, no @mentions, no forged marker.
- An existing comment is edited only if it starts with the hidden marker and was written by the identity the tool posts as.
- Nothing in Chaffbroom Tollbook calls a server of ours. A planned hosted org-wide report (Enterprise, not built yet) would receive only counts and costs per repo and workflow, never logs.
Limits
- All figures and the budget gate use list price (gross). Included minutes and discounts are not deducted because GitHub does not expose them per job or PR.
- Self-hosted runners count as $0. Standard runners on public repos count as $0.
- Larger-runner labels are yours: map them in runner_map in .tollbook.yml. Unmapped labels count $0 and show a warning.
- macOS larger-runner labels are unverified against the price reference; a job priced through one gets a warning.
- The gate counts only jobs finished when the cost job runs. A later rerun or another workflow can push the PR over budget after the check passed.
- Rerun dedupe is unverified against a real payload: how GitHub lists carried-over jobs on a re-run of failed jobs is not documented.
- The billing usage report only goes down to repository level, so it cannot split cost by PR or workflow.
More in Chaffbroom
Install Chaffbroom Tollbook
What GitHub Actions costs per pull request, reruns and cancelled runs included, as a sticky comment.
Set up Chaffbroom (https://github.com/chaffbroom/chaffbroom) in this repository and try it. Chaffbroom is two free tools, source available under FSL-1.1-ALv2, that run with my own tokens and send nothing anywhere: Winnow finds stale preview environments, Tollbook shows what GitHub Actions costs per pull request. Rules: - Before you add or edit any file, list the files and the change, and wait for my yes. - Never ask me to paste a token or secret into this chat, and never print one. Use tokens already in the environment, or `gh auth token`. I add repository secrets myself. - Read only: never run winnow apply, never post a comment, never open an issue. - No key, account or payment is needed. Support and the org-wide report are Enterprise: chaffbroom@sivakoza.ai. Do not try to set those up. Steps: 1. Use the npm package chaffbroom: `npx chaffbroom ...`. It is one bundled file with no dependencies and needs Node 20+; npx fetches it on first use (add --yes after npx if the shell cannot answer npx's question). 2. Tollbook: run npx chaffbroom tollbook weekly --repo <owner/name> --days 7 --top 5 --format json with GITHUB_TOKEN from `gh auth token` (it needs actions: read). Sum up the total cost, the top workflows and the rerun waste. Money is in micro-dollars, at list price. 3. Run npx chaffbroom init --dry-run and show me what it would write: .winnow.yml with the preview providers it found, and the workflows (Winnow starts in plan mode). If it found the wrong providers, run it again with --provider <id>. After my yes, run the same command with --yes instead of --dry-run, and show me the `gh secret set` lines it prints; I run those myself. Say that the jobs use GitHub Actions minutes, which GitHub bills on private repositories. 4. Once I have filled in the ids in .winnow.yml, run npx chaffbroom winnow plan --format json and report what would be deleted, and which providers were skipped for a missing token.