Increasing GitHub Actions Disk Space

A couple of days ago, all of the sudden, my jobs started running out of space.

I was probably in the verge of using all disk space for a while now, and something got just slightly bigger, just enough so it became a real problem.

Oops...

Oops...

After some digging and debugging, I found out that, commonly, an ubuntu-latest GitHub Actions worker has around 21GB of free disk space. I also found out that paying doesn’t give you more space. The only way to go is custom workers.

In my case, that seemed like a bit too much, so I started looking into things.

What’s using all that space in the action worker?

The /dev/root file system is ~73G… so how come it has only 21 free?

Turns out, it comes with a bunch of things I don’t need:

  • a bunch of Docker images (e.g. node)
  • Android SDK
  • Haskell compiler
  • Dotnet SDK
  • CodeQL Cache

So, I added this to my YAML:

# ...
steps:
  - run: df -h
  - name: "node-cleanup"
    run: |
      sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
      sudo docker image prune --all --force
      sudo docker builder prune -a      
  - run: df -h
# ...

And, not too much of a surprise, but it did help quite a bit:

Save some space with this one weird trick!

Save some space with this one weird trick!

Giving credit where credit is due, I took that from the Maximize Build Disk Space Action. I didn’t used it because it seemed easier to just delete things myself.

Why am I using that much space? And am I really?

First, the repository itself isn’t that small anymore, with approximately 90MB - and that would be x2, as we use Go mod proxying to build.

Plus, it depends on some rather big libraries, like Docker (Docker alone is around 40MB), AWS stuff… All that consumes about 2.7GB.

Building “just” the binaries for all platforms (currently 10) takes another 1.7GB. Then there’s all the archives, packages, and so on.

The Docker images take another 1GB each.

So, all that, plus all the tooling that needs to be installed in the worker (Nix, Snapcraft, etc), plus some temp files that I’m sure also exist somewhere, it’s not that long of a stretch to hit that 20GB.

I added a df -h at the end of the build, and we can observe the whole thing in action:

Used ~20GB indeed

Used ~20GB indeed

So, yeah, somehow, I’m definitely using a lot of space.

Future

It would be nice to have a ubuntu-slim-latest, or more disk space if you pay.

This feels like a hack - probably because it is, and I’m pretty sure we will be talking about this again in the future when it comes back to bite me again.


Footnotes

  • I also posted about this on Twitter.
  • You can also check the pull request containing these changes.