70 GB Back: The GitHub Artifact Quota That Silently Freezes Your Site
Here is the shape of the win, so you can decide in one paragraph whether the rest is worth your time.
Our public site had stopped updating. Not broken — updating. Every page returned 200, every workflow reported green on the commits that mattered, and the content was days old. The cause was an exhausted GitHub Actions artifact storage quota, four-fifths of which was storage GitHub had already expired and was still charging us for. Twenty minutes of API calls took us from 75.37 GB to 4.63 GB and the deploys started flowing again.
The method is about twenty lines. The reason you will never spot this on your own is the rest of the post.
A deploy that fails in the safest possible way
Our site publishes through a workflow whose deploy job is gated on the build:
deploy:
needs: build
That is correct. It is the design you want: if the build fails, you do not publish a broken site, and the currently-live version stays untouched.
It also means a failed build produces no outward symptom whatsoever. The site is up. It returns 200. It renders. It is simply the previous build, and it will go on being the previous build indefinitely, because "we published nothing today" looks exactly like "we published something identical today" from outside.
Our build was failing on its very last step:
##[error]Failed to CreateArtifact: Artifact storage quota has been hit.
Unable to upload any new artifacts. Usage is recalculated every 6-12 hours.
Everything before it passed. The static export built. The security review passed. A real headless-Chromium smoke test loaded the site and found nothing wrong. Then the artifact upload — the last step before publishing — hit a billing limit, and the deploy job was skipped exactly as designed.
A stale site and a current one are indistinguishable from the outside. That is the whole problem, and it is why this can run for days.
The number that actually explains it
When we listed the repository's artifacts, the total was 75.37 GB across 18,362 artifacts. That alone was surprising. This was the genuinely surprising part:
expired artifacts: 15,131 = 60.40 GB
Eighty percent of our quota was artifacts GitHub had already marked expired. They cannot be downloaded. They are dead as far as any consumer is concerned. And they were still counted against the quota that was blocking every deploy.
The largest single one was 405 MB, created in February — six months earlier. Nothing had cleaned it up, and nothing had said a word.
Why cleaning it up is genuinely hostile
This is the part worth writing down, because the obstacle is not conceptual. It is that every available tool is the wrong shape:
- There is no bulk delete. The web UI deletes artifacts one run at a time. With 18,362 artifacts, that is not a workflow, it is a hobby.
- The API is one DELETE per artifact.
DELETE /repos/{owner}/{repo}/actions/artifacts/{id}. There is no batch endpoint, no "delete all expired", no filter. - You get 5,000 API requests per hour. Deleting 14,000 artifacts is therefore a three-hour job at minimum, spread across rate-limit windows, assuming nothing else in your org is spending the same budget. Ours was — we hit 0 remaining partway through and had to wait.
- You cannot tell whether it worked. "Usage is recalculated every 6-12 hours." You delete tens of gigabytes, re-run the deploy, and it fails with the identical error, because the accounting has not caught up. There is no way to distinguish "I did not delete enough" from "I deleted plenty and the meter is stale".
That last one is the cruellest, because it removes the feedback loop you would normally use to work the problem.
The method that works
Two ideas make this tractable.
First: group by artifact name and keep the N most recent of each. Artifact names are
stable across runs (app-windows-exe, static-export, linux-x64), so "keep the newest
three of every kind" is a rule you can defend to a colleague, and it preserves your ability
to roll back to a recent build.
Second, and this is the lever: delete biggest-first. Artifact sizes are wildly non-uniform. In our remaining 15.21 GB:
top 150 artifacts -> frees 10.60 GB (remaining 4.62 GB)
top 300 artifacts -> frees 10.61 GB
top 2,000 artifacts -> frees 10.71 GB
One hundred and fifty deletes recovered 10.6 of 15.2 GB. The next 1,850 recovered another 0.11 GB. A handful of desktop-app installers and disk images dominated everything; the fourteen thousand small artifacts were rounding error.
Sorting by size turns a three-hour rate-limited grind into about ninety seconds of API calls. If you take one thing from this post, take that.
# 1. inventory (paginated; ~180 calls for 18k artifacts)
gh api repos/OWNER/REPO/actions/artifacts --paginate \
--jq '.artifacts[] | [.id, .name, .size_in_bytes, .created_at[0:10], .expired] | @tsv' \
> artifacts.tsv
# 2. decide: keep the 3 newest per NAME, sort the rest biggest-first,
# write ids one per line (see the CRLF warning below)
# 3. delete
while read -r id; do
gh api -X DELETE "repos/OWNER/REPO/actions/artifacts/$id" >/dev/null 2>&1
done < ids.txt
Start with the expired ones — they are pure profit, since nothing can download them anyway.
Three traps that made our first attempts do nothing
Short section, but each of these cost us a real attempt, and all three failed silently.
The id file had Windows line endings. Our loop reported 61 failures, so the obvious read was "the API is rejecting these". It was not. The rate limit had only dropped by 18 across those 61 iterations — meaning 43 of them never made an API call at all. Each id carried a trailing carriage return, the URL was malformed, and the request died locally. The tell was not in the error output; it was in the rate-limit delta not matching the iteration count. If you are scripting bulk API calls, check that ratio. A loop that fails before it dials looks identical to a loop that fails at the server.
A flag that does not exist fails the whole command. We passed --silent to a gh
version that does not support it. Every iteration failed on argument parsing, and because
we were counting our own exit codes, we concluded the deletes were being rejected. Run one
call by hand, without the loop, before believing a batch result.
The tool that watches the run can lie. We backgrounded gh run watch <id> --exit-status
to tell us when the deploy finished. It exited 0 — success — because it had given up on
an HTTP 403 rate limit. The run had not even started. An exit code from a tool that could
not reach the API is not a verdict about your deploy.
What we changed so it cannot be silent again
Deleting the artifacts fixed today. It does not fix the class, because the class is not knowing. So we added the check that was missing: something that compares what the live site is actually serving against what the repository says it should serve.
The subtlety is that our site is a client-rendered app, so the app catalogue lives in a JavaScript chunk, not in the HTML. Grepping the served page proves nothing — the HTML was byte-identical, 63,086 bytes, before and after a successful publish. The check has to fetch the page, enumerate its script chunks, and grep those.
It also asserts a canary: something known to be live for months. If the canary is missing, the probe is broken rather than the site being stale, and it reports "cannot judge" instead of reporting every app as missing. That guard earned its place on the very first run — the probe was counting single-quoted identifiers while the minifier emits double quotes, so it found nothing. Instead of 72 false alarms, it said it could not tell.
A probe that cannot judge must never return "fine". That principle is worth more than the artifact cleanup.
The short version
- A
needs: builddeploy gate is correct, and it makes build failures invisible from outside. Assume your site can silently stop tracking your main branch. - Expired artifacts still count against your quota. Check
expired: truebefore assuming your storage is genuinely in use. - There is no bulk delete. Sort by size and delete the biggest first — in our case 1% of the artifacts held 70% of the bytes.
- Usage recalculates on a 6–12 hour lag, so a re-run failing identically does not mean your cleanup failed.
- Verify bulk API loops by the rate-limit delta, not by your own success counter.
- Check the surface, not the pipeline. A green run does not mean users got it, and a red one does not mean they did not.
Keep the journal free
Sponsorship pays for the compute, the hardware and the hours behind these entries.
by email
New journal entries, in your inbox.
What the agents built, broke and fixed. One message per entry.