Skip to main content
26 lines of YAML → $4,700 a year saved on a CI scan nobody saw the bill for

26 lines of YAML → $4,700 a year saved on a CI scan nobody saw the bill for

· 9 min read
Samuel Cozannet
Co-founder & CPTO, Cloud ex Machina

26 lines of YAML → $4,700 a year saved.

That's what one GitHub Actions security scan was worth once it checked only the code each merge changed. Before the fix, it cost about $2 every time someone merged to the main branch. Nobody looks twice at $2, but at 48 merges a week it made up roughly three quarters of the repository's CI bill, mostly spent re-checking code that had been checked minutes earlier.

Now the same check costs $126 a year instead of $4,830. The fix was one pull request. The hard part was getting the cost in front of the people who write CI, a group that now includes coding agents, because none of them ever see the bill.

Cumulative cost of one CI security scan on every merge. Before the fix, spend climbs by $1.93 per merge to about $89 over ten days. After the Cloud ex Machina fix merged, it rises by only $2 in a week, while the old scan would have reached $182, so $90 was avoided in the first week

Why the CI bill never reaches whoever writes the workflow​

A workflow author sees a green check and a duration on each pull request, and hears about it fast when a workflow gets slow, because people wait for it. The money goes somewhere else. On GitHub, organization usage data goes to owners and billing managers, as a bill for the whole organization.

So the loop reports speed back to the author and never reports cost. From where the author sits, a workflow that runs fast and passes is a good workflow. The owner who reads the bill sees one total and can't tell which of dozens of workflows drove it. And at $2 a run, no single run looks worth a question.

How a ten-minute scan costs $2 a run​

The scan runs as a matrix with one job per Terraform directory. With about 130 directories, plus the jobs around them, a full run started about 265 jobs in parallel. That's why it finished in six to ten minutes.

GitHub rounds each job up to the next whole minute and charges $0.006 a minute for a Linux 2-core runner. A job that runs 20 seconds pays for a full minute, and across 265 short jobs the rounding adds up fast. In three full runs, the jobs ran for 699 minutes and billed 1,196, so 42% of the money paid for rounding.

The full scan also ran after the checking was done. A pull request already scanned the directories it changed, and a required gate scanned the whole repository. The merge to main then triggered a full scan of every directory again, for code that had been checked minutes earlier.

You can run the same check on any workflow run in a minute. This command sums the runtime of each job and the minutes GitHub bills for it:

gh api --paginate "repos/OWNER/REPO/actions/runs/RUN_ID/jobs?filter=all&per_page=100" \
--jq '.jobs[] | select(.started_at and .completed_at) | ((.completed_at | fromdate) - (.started_at | fromdate))' \
| awk '{s += $1; b += int(($1 + 59) / 60)} END {printf "jobs %d, runtime %.0f min, billed %d min\n", NR, s / 60, b}'

On one full scan it printed jobs 265, runtime 261 min, billed 426 min, about $2.56 for a run that took nine minutes on the clock.

Cancelling superseded runs saved little​

The workflow already cancelled a scan when a newer merge arrived, which is the usual advice for cutting CI cost. A third of the full scans were cancelled that way, and each cancelled run still cost $1.10 on average.

Cancellation stops the jobs that are still running and refunds nothing. With 265 jobs starting within seconds of each other, most of the money was spent by the time the next merge landed. Early cancellation pays off on a long serial pipeline, where most of the work is still queued when the newer push arrives, and a wide fan-out of short jobs has already run.

Scanning what the merge changed cut the cost per merge from $1.93 to $0.05​

The fix made a push to main scan only the directories it changed, the same scope as the pull request. A weekly run still scans every directory. The required gate on pull requests didn't change.

Push scan on mainCost per mergePer year, at 48 merges a week
Full scan on every merge$1.93$4,830
Only the changed directories$0.05$126

xkcd 1205, Is It Worth the Time? A table of how long you can work on making a routine task more efficient before you spend more time than you save, across five years, by how often you do the task and how much time you shave off

Is It Worth the Time? by Randall Munroe, xkcd, licensed CC BY-NC 2.5.

Randall's table, read for money instead of time, gives the same answer. Shaving $1.88 off something that happens 48 times a week is worth about $4,700 a year, for one pull request.

In exchange, a merge that changes a shared Terraform module now scans the module and not every root that calls it, so a finding in a caller can wait up to a week for the weekly full scan. The blocking control was always the gate on the pull request, and it still scans the whole repository.

Batching the matrix into fewer, longer jobs would cut the rounding on every remaining run too. Scoping the scan removed 97% of the cost on its own, so batching is the next step for the workflows that still fan out wide.

Coding agents merge more and read no bill​

A check that costs $2 per merge scales with the number of merges, and coding agents raise that number. An agent opens pull requests around the clock, rebases them and pushes fixes after each review. Each push can start a workflow. When an agent edits a workflow, adding a matrix entry or a push trigger, it judges the change the way a person would, by whether it passes and how long it takes.

Nothing in that loop carries the price, the same gap that leaves AI writing application code blind to cloud cost. The agent can read every line of the YAML and has no way to know that the line it just added costs $2 a merge, or $4,800 a year at the repository's pace. Unless the cost of a workflow comes back to where the workflow is written and reviewed, next to the duration and the green check, every agent that touches CI keeps making the same reasonable choice.

Cloud ex Machina closes that loop. Our GitHub integration reads every workflow run and job with its billable minutes, and we reconcile that cost with the bills of every cloud and SaaS tool you connect, so CI sits in the same view as compute, observability and AI spend. We price each workflow and each job, flag the ones that pay for rounding or repeat work, and deliver the fix to the team that owns the workflow as an application-layer FinOps recommendation, with its saving in dollars. Our plugin for Claude brings the same cost context into the coding agent while it writes, so the next workflow change starts from what the last one cost.

Other GitHub Actions workflows that pay for rounding​

Security scans are one case. Any workflow that fans out into many short jobs pays the rounding on each one: per-package linting, per-directory validation, a test matrix where most cells finish in seconds. Any workflow that runs again on merge, after the pull request already ran it, pays twice for the same answer. Neither looks slow, and both look fine on the only dashboard a workflow author opens, which shows a green check and a duration and nothing about what the run cost.

For a first check today, take your three most frequent workflows, run the command above on one recent run of each, and compare the billed minutes to the time on the clock. This scan came out at about 48 to 1. Anything far above 1 is a wide fan-out of short jobs, and you pay the rounding on every run.

FAQ: GitHub Actions cost and billing​

How does GitHub bill Actions minutes?​

For GitHub-hosted runners in private repositories, GitHub bills per job and rounds each job up to the nearest whole minute. A workflow with 200 jobs of 20 seconds pays for 200 minutes, though the jobs ran for about 67.

Does cancelling a GitHub Actions run save money?​

It saves what the remaining jobs would have used, and nothing that already ran. In this repository, cancelled full scans still cost $1.10 each on average, because their jobs had started in parallel before the cancellation arrived.

Who can see GitHub Actions usage in an organization?​

Owners and billing managers can see the organization's usage data. Most people who write workflows have neither role, and coding agents have none, so neither sees what a workflow costs.