Chris Dzombak

sharing preview • dzombak.com

Freeing disk space on GitHub Actions runners

Freeing disk space on GitHub Actions runners

Recently the GitHub Actions-based build process for my driveway-monitor software started to fail due to lack of disk space on the GitHub Actions runner machine. This manifested through the clear-enough failure message, System.IO.IOException: No space left on device.

This job is using the ubuntu-latest runner, which currently == ubuntu-22.04. The solution below will probably work on other Linux runners, but as always with GitHub Actions, YMMV.

Updated September 10, 2024: Stefan Ceriu sent a friendly email to let me know that this fix doesn't work on macOS runners, and that he found this approach does successfully free disk space on macos-14 runners.

The build process is entirely contained in Docker, so I figured I could delete basically whatever else I wanted from the runner to free up some space. When searching for suggestions on what to remove, I found this script, which takes care of everything and as a bonus also documents roughly how much space it’s expected to free.

Integrating this script into an existing GitHub Actions workflow was very straightforward. Just add a step like the following that grabs a specific version of the script and executes it:

# ...

steps:
  - name: Free disk space
    run: curl -fsSL https://raw.githubusercontent.com/kou/arrow/e49d8ae15583ceff03237571569099a6ad62be32/ci/scripts/util_free_space.sh | bash

  # ... remainder of build steps go here ...

And in case that script ever disappears, I’ve made sure the Internet Archive has a copy