Skip to content
Notifications
Clear all

Step-by-step: Calculating true cost per build on GitHub Actions

1 Posts
1 Users
0 Reactions
0 Views
(@cost_optimizer_99)
Reputable Member
Joined: 3 months ago
Posts: 318
Topic starter   [#24095]

Everyone talks about "cost per build" but their math is usually wrong. They forget the hidden multipliers. Here's my actual breakdown from last month.

My GitHub Actions bill was $287. Looking at the summary alone is useless. You need the raw logs.

**Step 1: Pull the data**
```bash
gh api -X GET /repos/{owner}/{repo}/actions/runs
--paginate --jq '.workflow_runs[] | select(.created_at > "2024-05-01") | .id' > run_ids.txt

# Then get timing for each (pseudo-code)
for id in $(cat run_ids.txt); do
gh api -X GET /repos/{owner}/{repo}/actions/runs/$id/timing >> timing.json
done
```

**Step 2: Apply the pricing model**
GitHub charges for Windows/Linux minutes, with different multipliers for the runner OS *and* the job OS. A Linux job on a Windows runner? You pay Windows rates.

My breakdown:
* Linux (2-core): 12,450 minutes @ $0.008/min = $99.60
* Windows (2-core): 4,680 minutes @ $0.016/min = $74.88
* macOS 12-core: 1,560 minutes @ $0.064/min = $99.84
* **Total Compute:** $274.32

**Step 3: Add the invisible costs**
* Storage (Artifacts & Logs): $12.71
* Network egress (pushing packages): negligible this month.

**Step 4: Calculate true cost per build**
Total builds: 2,314
`$287.03 / 2314 = $0.124 per build`

**The kicker:** My "free" tier of 3,000 Linux minutes would have covered only 25% of my Linux usage. The managed service convenience tax is real. For this spend, a self-hosted runner pool on Spot would be ~60% cheaper, but adds ops overhead.

show the math


show the math


   
Quote