mirror of
https://github.com/jlumbroso/free-disk-space.git
synced 2026-01-28 13:39:07 +08:00
Added tool-cache opt thx to @miketimofeev 🙏🏻
This commit is contained in:
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -8,3 +8,13 @@ jobs:
|
||||
# If there is a problem with this GitHub Actions, this step will fail
|
||||
- name: Free Disk Space
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: true
|
||||
|
||||
# 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
|
||||
|
||||
15
README.md
15
README.md
@@ -2,9 +2,11 @@
|
||||
|
||||
A customizable GitHub Actions to free disk space on Ubuntu GitHub Actions runners.
|
||||
|
||||
On a typical Ubuntu runner, with all options turned on (or not turned off rather), this can clear up to 25 GB of disk space in about 3 minutes (the longest period is calling `apt` to uninstall packages).
|
||||
On a typical Ubuntu runner, with all options turned on (or not turned off rather), this can clear up to 25 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](https://github.com/jlumbroso/free-disk-space/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! 😊
|
||||
Please don't hesitate to [submit issues](https://github.com/jlumbroso/free-disk-space/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
|
||||
|
||||
@@ -20,6 +22,9 @@ jobs:
|
||||
- name: Free Disk Space (Ubuntu)
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
# this might remove tools that are actually needed
|
||||
tool-cache: false
|
||||
|
||||
# all of these default to true, but feel free to set to
|
||||
# false if necessary for your workflow
|
||||
android: true
|
||||
@@ -28,6 +33,11 @@ jobs:
|
||||
large-packages: 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](https://github.com/actions/virtual-environments/blob/5a2cb18a48bce5da183486b95f5494e4fd0c0640/images/linux/scripts/installers/configure-environment.sh#L25-L29) (the same environment variable is used across Windows/macOS/Linux runners, see an example of its use on [the `setup-python` GitHub Action](https://github.com/actions/setup-python)). This option was [suggested](https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159) by [@miketimofeev](https://github.com/miketimofeev).
|
||||
|
||||
## Acknowledgement
|
||||
|
||||
@@ -37,6 +47,7 @@ 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
|
||||
- https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
|
||||
|
||||
## Typical Output
|
||||
|
||||
|
||||
22
action.yml
22
action.yml
@@ -20,13 +20,20 @@ inputs:
|
||||
required: false
|
||||
default: "true"
|
||||
|
||||
# option inspired after:
|
||||
# option inspired by:
|
||||
# https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
|
||||
large-packages:
|
||||
description: "Remove large packages"
|
||||
required: false
|
||||
default: "true"
|
||||
|
||||
# option inspired by:
|
||||
# https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
|
||||
tool-cache:
|
||||
description: "Remove image tool cache"
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
swap-storage:
|
||||
description: "Remove swap storage"
|
||||
required: false
|
||||
@@ -173,6 +180,19 @@ runs:
|
||||
printSavedSpace $SAVED "Large misc. packages"
|
||||
fi
|
||||
|
||||
# Option: Remove tool cache
|
||||
# REF: https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
|
||||
|
||||
if [[ ${{ inputs.tool-cache }} == 'true' ]]; then
|
||||
BEFORE=$(getAvailableSpace)
|
||||
|
||||
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
||||
|
||||
AFTER=$(getAvailableSpace)
|
||||
SAVED=$((AFTER-BEFORE))
|
||||
printSavedSpace $SAVED "Tool cache"
|
||||
fi
|
||||
|
||||
# Option: Remove Swap storage
|
||||
|
||||
if [[ ${{ inputs.swap-storage }} == 'true' ]]; then
|
||||
|
||||
Reference in New Issue
Block a user