💡 This is a fork of https://github.com/jlumbroso/free-disk-space, only difference is that it's maintained actively.
A customizable GitHub Action to free disk space on Ubuntu GitHub Action runners.
On a typical Ubuntu runner, with all options turned on (or not turned off rather), this can clear up to 34 GB of disk space in 4-5 minutes (the longest period is calling apt
to uninstall packages). This is useful when you need a lot of disk space to run computations.
name: Free Disk Space (Ubuntu)
on: push
jobs:
reclaim:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: insightsengineering/disk-space-reclaimer@v1
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tools-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
docker-images: true
tools-cache: true
Most of the options are self-explanatory.
The option tools-cache
removes all the pre-cached tools (Node, Go, Python, Ruby, ...) that are loaded in a runner's environment, installed in the path specified by the AGENT_TOOLSDIRECTORY
environment variable (the same environment variable is used across Windows/macOS/Linux runners, see an example of its use on the setup-python
GitHub Action). This option was suggested by @miketimofeev.
This GitHub Actions came around because I kept rewriting the same few lines of rm -rf
code.
Here are a few sources of inspiration:
- https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
- https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
- https://github.com/ShubhamTatvamasi/free-disk-space-action
- actions/runner-images#2875 (comment)
- https://github.com/easimon/maximize-build-space/
The amount of space storage saved by each option on an ubuntu-22.04
runner is summarized here:
=> Android library: Saved 12GiB
=> .NET runtime: Saved 1.7GiB
=> Haskell runtime: Saved 0B
=> Large misc. packages: Saved 4.6GiB
=> Docker images: Saved 3.6GiB
=> Tool cache: Saved 8.4GiB
=> Swap storage: Saved 4.0GiB
=> Saved 30GiB
=> Total 34GiB