Free up to 42 GB of additional disk space on GitHub Actions runners by removing unnecessary preinstalled software.
GitHub-hosted runners provide approximately 22 GB of free disk space by default. If your build requires more space, this action can help by removing unused software packages and optimizing disk usage.
- This action is a hack, really, and on a "works for me" basis. Runner configuration might change in the future - up to the point where this action ceases to work
- For sure you're voiding the warranty on Github runners when using this
- Removal of unnecessary software is currently implemented by
rm -rfon specific folders, only a fraction by a package manager, and definitely by nothing sophisticated. While this is quick and easy, it might delete dependencies that are required by your job and so break your build
GitHub-hosted runners use Azure Standard_D4ads_v5 virtual machines with:
- 75 GB OS disk mounted on
/ - 75 GB temp disk mounted on
/mnt
Of the 72 GB root filesystem, only ~22 GB is available by default. The remainder is consumed by preinstalled build tools and software. See GitHub runner images for details on what's included.
This action frees up space by:
- (Optionally) removes unwanted preinstalled software
- (Optionally) disables & removes the swapfile
- (Optionally) sets
TMPDIRenvironment variable to point to/mnt, so that temporary files created by build tools are stored on the ephemeral disk instead of the root disk
Result: Up to 42 GB of additional space becomes available for your builds
Note
All removal options are disabled by default. Enable only the options your build requires
Tip
More enabled options = longer execution time. Balance space needs with workflow performance
name: Build with Extended Disk Space
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: nepalevov/maximize-build-space@v1 # x-release-please-major
with:
remove-android: 'true'
# Other options as needed
- name: Checkout
uses: actions/checkout@v5
- name: Build
run: |
echo "Available disk space:"
df -hSee action.yml for a complete list of available removal options.
Inspired by: