Skip to content

Commit

Permalink
Add fine-switch
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Sep 16, 2023
1 parent 582592d commit 7601fec
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 81 deletions.
68 changes: 49 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This project is inspired from:
- [ShubhamTatvamasi/free-disk-space-action](https://github.com/ShubhamTatvamasi/free-disk-space-action)
- [ThewApp/free-actions](https://github.com/ThewApp/free-actions)

> **⚠️ Important:** This documentation is v0.5.0 based; To view other version's documentation, please visit the [versions list](https://github.com/hugoalh/disk-space-optimizer-ghaction/tags) and select the correct version.
> **⚠️ Important:** This documentation is v0.7.0 based; To view other version's documentation, please visit the [versions list](https://github.com/hugoalh/disk-space-optimizer-ghaction/tags) and select the correct version.
## 🌟 Feature

Expand All @@ -44,7 +44,7 @@ This project is inspired from:

### GitHub Actions

- **Target Version:** Runner >= v2.303.0, &:
- **Target Version:** Runner >= v2.308.0, &:
- PowerShell >= v7.2.0
- **Require Permission:** *N/A*

Expand All @@ -58,80 +58,110 @@ jobs:
## 🧩 Input
> **ℹ️ Notice:** All of the inputs are optional; Use this action without any input will default to do nothing.
### `input_listdelimiter`

**\[Optional\]** `<RegEx = ",|;|\r?\n">` Delimiter when the input is accept list of values, by regular expression.
`<RegEx = ",|;|\r?\n">` Delimiter when the input is accept list of values, by regular expression.

### `operate_async`

> **🧪 Experimental:** This is in testing, maybe available in the latest version and/or future version.

**\[Optional\]** `<Boolean = False>` Whether to operate in asynchronously to reduce the operation duration.
`<Boolean = False>` Whether to operate in asynchronously to reduce the operation duration.

### `operate_sudo`

**(>= v0.6.0) \[Optional\]** `<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.
`<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.

### `general_include`

**\[Optional\]** `<RegEx[]>` Remove general item, by regular expression and [general list][list], separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).
`<RegEx[]>` Remove general item, by regular expression and [general list][list], separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).

### `general_exclude`

**\[Optional\]** `<RegEx[]>` Exclude remove general item, by regular expression and [general list][list], separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).
`<RegEx[]>` Exclude remove general item, by regular expression and [general list][list], separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).

### `docker_include`

**\[Optional\]** `<RegEx[]>` Remove Docker image, by regular expression, separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).
`<RegEx[]>` Remove Docker image, by regular expression, separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).

### `docker_exclude`

**\[Optional\]** `<RegEx[]>` Exclude remove Docker image, by regular expression, separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).
`<RegEx[]>` Exclude remove Docker image, by regular expression, separate each name by [list delimiter (input `input_listdelimiter`)](#input_listdelimiter).

### `docker_prune`

**\[Optional\]** `<Boolean = False>` Whether to prune Docker all of the dangling images.
`<Boolean = False>` Whether to prune Docker all of the dangling images.

### `docker_clean`

**\[Optional\]** `<Boolean = False>` Whether to remove Docker cache, include all of the:
`<Boolean = False>` Whether to remove Docker cache, include all of the:

- build caches
- stopped/unused containers
- dangling and/or unreferenced images
- unused networks

### `apt_enable`

`<Boolean = True>` Whether to optimize via APT. Only affect general optimization.

### `apt_prune`

**\[Optional\]** `<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 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.

### `apt_clean`

**\[Optional\]** `<Boolean = False>` Whether to remove APT (Advanced Packaging Tools) cache, include the local repository of retrieved package files.
`<Boolean = False>` Whether to remove APT (Advanced Packaging Tools) cache, include the local repository of retrieved package files.

### `chocolatey_enable`

`<Boolean = True>` Whether to optimize via Chocolatey. Only affect general optimization.

### `homebrew_enable`

`<Boolean = True>` Whether to optimize via Homebrew. Only affect general optimization.

### `homebrew_prune`

**\[Optional\]** `<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 prune Homebrew all of the packages that were only installed as a dependency of other packages and are now no longer needed.

### `homebrew_clean`

**\[Optional\]** `<Boolean = False>` Whether to remove Homebrew cache, include all of the:
`<Boolean = False>` Whether to remove Homebrew cache, include all of the:

- outdated downloads
- old versions of installed formulae
- stale lock files

### `npm_enable`

`<Boolean = True>` Whether to optimize via NPM. Only affect general optimization.

### `npm_prune`

**\[Optional\]** `<Boolean = False>` Whether to prune NPM (NodeJS Package Manager) all of the extraneous packages.
`<Boolean = False>` Whether to prune NPM (NodeJS Package Manager) all of the extraneous packages.

### `npm_clean`

**\[Optional\]** `<Boolean = False>` Whether to remove NPM (NodeJS Package Manager) cache.
`<Boolean = False>` Whether to remove NPM (NodeJS Package Manager) cache.

### `pipx_enable`

`<Boolean = True>` Whether to optimize via Pipx. Only affect general optimization.

### `wmic_enable`

`<Boolean = True>` Whether to optimize via WMIC. Only affect general optimization.

### `fs_enable`

`<Boolean = True>` Whether to optimize via file system.

### `os_swap`

**\[Optional\]** `<Boolean = False>` Whether to remove system page/swap file.
`<Boolean = False>` Whether to remove system page/swap file.

## 🧩 Output

Expand All @@ -145,7 +175,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Optimize Disk Space"
uses: "hugoalh/disk-space-optimizer-ghaction@v0.6.0"
uses: "hugoalh/disk-space-optimizer-ghaction@v0.7.0"
with:
operate_sudo: "True"
general_include: ".+"
Expand Down
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
| **Versions** | **Status** | **Target - GitHub Actions Runner** | **Target - PowerShell** |
|:-:|:-:|:-:|:-:|
| v0.7.X | ✔️ | >= v2.308.0 | >= v7.2.0 |
| v0.6.X | ✔️ | >= v2.303.0 | >= v7.2.0 |
| v0.5.X | ✔️ | >= v2.303.0 | >= v7.2.0 |
| v0.4.X | 👎{🧓} | >= v2.303.0 | >= v7.2.0 |
Expand Down
85 changes: 46 additions & 39 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ inputs:
description: "{Boolean} Whether to remove Docker cache."
required: false
default: "False"
apt_enable:
description: "{Boolean} Whether to optimize via APT."
required: false
default: "True"
apt_prune:
description: "{Boolean} Whether to prune APT package."
required: false
Expand All @@ -46,6 +50,14 @@ inputs:
description: "{Boolean} Whether to remove APT cache."
required: false
default: "False"
chocolatey_enable:
description: "{Boolean} Whether to optimize via Chocolatey."
required: false
default: "True"
homebrew_enable:
description: "{Boolean} Whether to optimize via Homebrew."
required: false
default: "True"
homebrew_prune:
description: "{Boolean} Whether to prune Homebrew package."
required: false
Expand All @@ -54,6 +66,10 @@ inputs:
description: "{Boolean} Whether to remove Homebrew cache."
required: false
default: "False"
npm_enable:
description: "{Boolean} Whether to optimize via NPM."
required: false
default: "True"
npm_prune:
description: "{Boolean} Whether to prune NPM package."
required: false
Expand All @@ -62,38 +78,22 @@ inputs:
description: "{Boolean} Whether to remove NPM cache."
required: false
default: "False"
os_swap:
description: "{Boolean} Whether to remove system page/swap file."
required: false
default: "False"
dockerimage_include:
description: "{RegEx[]} Remove Docker image."
required: false
deprecationMessage: "Replaced by input `docker_include`!"
dockerimage_exclude:
description: "{RegEx[]} Exclude remove Docker image."
required: false
deprecationMessage: "Replaced by input `docker_exclude`!"
cache_apt:
description: "{Boolean} Whether to remove APT cache."
required: false
deprecationMessage: "Replaced by inputs `apt_prune` and `apt_clean`!"
cache_docker:
description: "{Boolean} Whether to remove Docker cache."
pipx_enable:
description: "{Boolean} Whether to optimize via Pipx."
required: false
deprecationMessage: "Replaced by inputs `docker_prune` and `docker_clean`!"
cache_homebrew:
description: "{Boolean} Whether to remove Homebrew cache."
default: "True"
wmic_enable:
description: "{Boolean} Whether to optimize via WMIC."
required: false
deprecationMessage: "Replaced by inputs `homebrew_prune` and `homebrew_clean`!"
cache_npm:
description: "{Boolean} Whether to remove NPM cache."
default: "True"
fs_enable:
description: "{Boolean} Whether to optimize via file system."
required: false
deprecationMessage: "Replaced by inputs `npm_prune` and `npm_clean`!"
swap:
description: "{Boolean} Whether to remove Linux Swap Space."
default: "True"
os_swap:
description: "{Boolean} Whether to remove system page/swap file."
required: false
deprecationMessage: "Replaced by input `os_swap`!"
default: "False"
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -136,22 +136,29 @@ runs:
}
shell: "pwsh"
env:
INPUT_APT_CLEAN: "${{inputs.cache_apt || inputs.apt_clean}}"
INPUT_APT_PRUNE: "${{inputs.cache_apt || inputs.apt_prune}}"
INPUT_DOCKER_CLEAN: "${{inputs.cache_docker || inputs.docker_clean}}"
INPUT_DOCKER_EXCLUDE: "${{inputs.dockerimage_exclude || inputs.docker_exclude}}"
INPUT_DOCKER_INCLUDE: "${{inputs.dockerimage_include || inputs.docker_include}}"
INPUT_DOCKER_PRUNE: "${{inputs.cache_docker || inputs.docker_prune}}"
INPUT_APT_CLEAN: "${{inputs.apt_clean}}"
INPUT_APT_ENABLE: "${{inputs.apt_enable}}"
INPUT_APT_PRUNE: "${{inputs.apt_prune}}"
INPUT_CHOCOLATEY_ENABLE: "${{inputs.chocolatey_enable}}"
INPUT_DOCKER_CLEAN: "${{inputs.docker_clean}}"
INPUT_DOCKER_EXCLUDE: "${{inputs.docker_exclude}}"
INPUT_DOCKER_INCLUDE: "${{inputs.docker_include}}"
INPUT_DOCKER_PRUNE: "${{inputs.docker_prune}}"
INPUT_FS_ENABLE: "${{inputs.fs_enable}}"
INPUT_GENERAL_EXCLUDE: "${{inputs.general_exclude}}"
INPUT_GENERAL_INCLUDE: "${{inputs.general_include}}"
INPUT_HOMEBREW_CLEAN: "${{inputs.cache_homebrew || inputs.homebrew_clean}}"
INPUT_HOMEBREW_PRUNE: "${{inputs.cache_homebrew || inputs.homebrew_prune}}"
INPUT_HOMEBREW_CLEAN: "${{inputs.homebrew_clean}}"
INPUT_HOMEBREW_ENABLE: "${{inputs.homebrew_enable}}"
INPUT_HOMEBREW_PRUNE: "${{inputs.homebrew_prune}}"
INPUT_INPUT_LISTDELIMITER: "${{inputs.input_listdelimiter}}"
INPUT_NPM_CLEAN: "${{inputs.cache_npm || inputs.npm_clean}}"
INPUT_NPM_PRUNE: "${{inputs.cache_npm || inputs.npm_prune}}"
INPUT_NPM_CLEAN: "${{inputs.npm_clean}}"
INPUT_NPM_ENABLE: "${{inputs.npm_enable}}"
INPUT_NPM_PRUNE: "${{inputs.npm_prune}}"
INPUT_OPERATE_ASYNC: "${{inputs.operate_async}}"
INPUT_OPERATE_SUDO: "${{inputs.operate_sudo}}"
INPUT_OS_SWAP: "${{inputs.swap || inputs.os_swap}}"
INPUT_OS_SWAP: "${{inputs.os_swap}}"
INPUT_PIPX_ENABLE: "${{inputs.pipx_enable}}"
INPUT_WMIC_ENABLE: "${{inputs.wmic_enable}}"
continue-on-error: true
- name: "Setup PowerShell Toolkit (Sudo)"
if: "${{inputs.operate_sudo == 'True'}}"
Expand Down
Loading

0 comments on commit 7601fec

Please sign in to comment.