Skip to content

BRAINSia/free-disk-space

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

58 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GitHub Actions to Free Disk Space on Ubuntu runners

A customizable GitHub Actions to free disk space on Linux GitHub Actions runners.

This is a revialization of the action deveoped at Original Project, but has not been maintained for several years.

On a typical Ubuntu runner, with all options turned on (or not turned off rather), this can clear up to 31 GB of disk space in about 3 minutes (the longest period is calling apt to uninstall packages). This is useful when you need a lot of disk space to run computations.

Please don't hesitate to submit issues to report problems or suggest new features (or sets of files to help remove).

Also, please โญ๏ธ the repo if you like this GitHub Actions! Thanks! ๐Ÿ˜Š

Example

name: Free Disk Space (Ubuntu)
on: push

jobs:
  free-disk-space:
    runs-on: ubuntu-latest
    steps:

    - name: Free Disk Space (Ubuntu)
      uses: BRAINSia/free-disk-space@v2
      with:
        # this might remove tools that are actually needed,
        # if set to "true" but frees about 6 GB
        tool-cache: false
        
        # all of these default to true, but feel free to set to
        # "false" if necessary for your workflow
        mandb:   true
        android: true
        dotnet: true
        haskell: true
        large-packages: true
        docker-images: true
        swap-storage: true

Options

Most of the options are self-explanatory.

The option tool-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.

Acknowledgement

This GitHub Actions came around because I kept rewriting the same few lines of rm -rf code.

Here are a few sources of inspiration:

Typical Output

The amount of space storage saved by each option on an ubuntu-24.04 runner is summarized here:

TIME_REPORT: =====================================================
TIME_REPORT:      subsection | time       seconds | size saved   |
TIME_REPORT: =====================================================
TIME_REPORT:    swap-storage | 0          seconds | 4.0GiB       |
TIME_REPORT:         haskell | 1          seconds | 6.2GiB       |
TIME_REPORT:          dotnet | 1          seconds | 3.3GiB       |
TIME_REPORT:      tool-cache | 6          seconds | 5.0GiB       |
TIME_REPORT:         android | 17         seconds | 9.6GiB       |
TIME_REPORT:  large-packages | 79         seconds | 4.6GiB       |
TIME_REPORT:           mandb | 12         seconds | 241MiB       |
TIME_REPORT:   docker-images | 0          seconds | 0B           |
TIME_REPORT: =====================================================
TIME_REPORT:            root | 139        seconds | 29GiB        |
TIME_REPORT: =====================================================
TIME_REPORT:         overall | 139        seconds | 33GiB        |
TIME_REPORT: =====================================================

About

:octocat:โš™๏ธ๐Ÿ—‘๏ธ A GitHub Action to free disk space on an Ubuntu runner.

Resources

License

Stars

Watchers

Forks

Packages

No packages published