A GitHub Action to optimize disk space for GitHub hosted GitHub Actions runner.
This project is inspired from:
- data-intuitive/reclaim-the-bytes
- easimon/maximize-build-space
- jlumbroso/free-disk-space
- ShubhamTatvamasi/free-disk-space-action
- ThewApp/free-actions
Important
This documentation is v0.8.0 based; To view other version's documentation, please visit the versions list and select the correct version.
- Always continue on error to not breaking any process.
- Support all of the platforms.
- Support multiple types:
- APT (Advanced Packaging Tools) caches
- APT (Advanced Packaging Tools) packages
- Chocolatey packages
- Directly bundled programs
- Docker caches
- Docker images
- Homebrew caches
- Homebrew packages
- NPM (NodeJS Package Manager) caches
- NPM (NodeJS Package Manager) packages
- OS page/swap file
- Pipx packages
- Windows programs (WMIC)
-
GitHub Actions Runner
π‘οΈ Require Permission
N/A
π½ Require Software
- PowerShell >= v7.2.0
- Import at the metadata (
action.yml
):runs: using: "composite" steps: - uses: "hugoalh/disk-space-optimizer-ghaction@<Tag>"
- Import at the workflow (
.github/workflows/<WorkflowName>.yml
):jobs: job_id: runs-on: "________" # Any steps: - uses: "hugoalh/disk-space-optimizer-ghaction@<Tag>"
Note
All of the inputs are optional; Use this action without any input will default to do nothing.
Legend Description π Switch with groups (e.g.: {E}
).
π§ͺ Experimental
This is in testing, maybe available in the latest version and/or future version.
<Boolean = False>
Whether to operate in asynchronously to reduce the operation duration.
<Boolean = False>
Whether to execute this action in sudo mode on non-Windows environment. This can set to True
in order to able operate protected resources on non-Windows environment.
<RegEx[]>
Remove general item, by regular expression and general list, separate each value per line.
<RegEx[]>
Exclude remove general item, by regular expression and general list, separate each value per line.
<RegEx[]>
Remove Docker image, by regular expression, separate each value per line.
<RegEx[]>
Exclude remove Docker image, by regular expression, separate each value per line.
<Boolean = False>
Whether to prune Docker all of the dangling images.
<Boolean = False>
Whether to remove Docker cache, include all of the:
- build caches
- stopped/unused containers
- dangling and/or unreferenced images
- unused networks
π{E} <Boolean = False>
Whether to optimize via APT. Only affect general optimization.
If all of the inputs inside this switch group are False
, this input will default to True
.
<Boolean = False>
Whether to prune APT (Advanced Packaging Tools) all of the packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
<Boolean = False>
Whether to remove APT (Advanced Packaging Tools) cache, include the local repository of retrieved package files.
π{E} <Boolean = False>
Whether to optimize via Chocolatey. Only affect general optimization.
If all of the inputs inside this switch group are False
, this input will default to True
.
π{E} <Boolean = False>
Whether to optimize via Homebrew. Only affect general optimization.
If all of the inputs inside this switch group are False
, this input will default to True
.
<Boolean = False>
Whether to prune Homebrew all of the packages that were only installed as a dependency of other packages and are now no longer needed.
<Boolean = False>
Whether to remove Homebrew cache, include all of the:
- outdated downloads
- old versions of installed formulae
- stale lock files
π{E} <Boolean = False>
Whether to optimize via NPM. Only affect general optimization.
If all of the inputs inside this switch group are False
, this input will default to True
.
<Boolean = False>
Whether to prune NPM (NodeJS Package Manager) all of the extraneous packages.
<Boolean = False>
Whether to remove NPM (NodeJS Package Manager) cache.
π{E} <Boolean = False>
Whether to optimize via Pipx. Only affect general optimization.
If all of the inputs inside this switch group are False
, this input will default to True
.
π{E} <Boolean = False>
Whether to optimize via WMIC. Only affect general optimization.
If all of the inputs inside this switch group are False
, this input will default to True
.
π{E} <Boolean = False>
Whether to optimize via file system.
If all of the inputs inside this switch group are False
, this input will default to True
.
<Boolean = False>
Whether to remove system page/swap file.
N/A
-
jobs: job_id: runs-on: "ubuntu-latest" steps: - name: "Optimize Disk Space" uses: "hugoalh/[email protected]" with: operate_sudo: "True" general_include: ". " docker_include: ". " docker_prune: "True" docker_clean: "True" apt_prune: "True" apt_clean: "True" homebrew_prune: "True" homebrew_clean: "True" npm_prune: "True" npm_clean: "True" os_swap: "True"
- GitHub Actions