Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hugoalh/disk-space-optimizer-ghaction

A GitHub Action to optimize disk space for GitHub hosted runner.
https://github.com/hugoalh/disk-space-optimizer-ghaction

disk gh-action ghaction github-action optimize

Last synced: about 1 month ago
JSON representation

A GitHub Action to optimize disk space for GitHub hosted runner.

Awesome Lists containing this project

README

        

[list]: ./list.json

# Disk Space Optimizer (GitHub Action)

[**โš–๏ธ** MIT](./LICENSE.md)

**๐Ÿ—‚๏ธ**
[![GitHub: hugoalh/disk-space-optimizer-ghaction](https://img.shields.io/badge/hugoalh/disk--space--optimizer--ghaction-181717?logo=github&logoColor=ffffff&style=flat "GitHub: hugoalh/disk-space-optimizer-ghaction")](https://github.com/hugoalh/disk-space-optimizer-ghaction)

**๐Ÿ†™** ![Latest Release Version](https://img.shields.io/github/release/hugoalh/disk-space-optimizer-ghaction?sort=semver&color=2187C0&label=&style=flat "Latest Release Version") (![Latest Release Date](https://img.shields.io/github/release-date/hugoalh/disk-space-optimizer-ghaction?color=2187C0&label=&style=flat "Latest Release Date"))

A GitHub Action to optimize disk space for GitHub hosted GitHub Actions runner.

This project is inspired from:

- [data-intuitive/reclaim-the-bytes](https://github.com/data-intuitive/reclaim-the-bytes)
- [easimon/maximize-build-space](https://github.com/easimon/maximize-build-space)
- [jlumbroso/free-disk-space](https://github.com/jlumbroso/free-disk-space)
- [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.8.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

- 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][list]
- [Chocolatey packages][list]
- [Directly bundled programs][list]
- Docker caches
- Docker images
- Homebrew caches
- [Homebrew packages][list]
- NPM (NodeJS Package Manager) caches
- [NPM (NodeJS Package Manager) packages][list]
- OS page/swap file
- [Pipx packages][list]
- [Windows programs (WMIC)][list]

## ๐ŸŽฏ Target

- GitHub Actions Runner
> **๐Ÿ›ก๏ธ Require Permission**
>
> *N/A*

> **๐Ÿ’ฝ Require Software**
>
> - PowerShell >= v7.2.0

## ๐Ÿ”ฐ Usage

### Composite Action

1. Import at the metadata (`action.yml`):
```yml
runs:
using: "composite"
steps:
- uses: "hugoalh/disk-space-optimizer-ghaction@"
```

### Workflow

1. Import at the workflow (`.github/workflows/.yml`):
```yml
jobs:
job_id:
runs-on: "________" # Any
steps:
- uses: "hugoalh/disk-space-optimizer-ghaction@"
```

## ๐Ÿงฉ Input

> [!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}`). |

### `operate_async`

> **๐Ÿงช Experimental**
>
> This is in testing, maybe available in the latest version and/or future version.

`` Whether to operate in asynchronously to reduce the operation duration.

### `operate_sudo`

`` 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`

`` Remove general item, by regular expression and [general list][list], separate each value per line.

### `general_exclude`

`` Exclude remove general item, by regular expression and [general list][list], separate each value per line.

### `docker_include`

`` Remove Docker image, by regular expression, separate each value per line.

### `docker_exclude`

`` Exclude remove Docker image, by regular expression, separate each value per line.

### `docker_prune`

`` Whether to prune Docker all of the dangling images.

### `docker_clean`

`` Whether to remove Docker cache, include all of the:

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

### `apt_enable`

**๐Ÿ”€{E}** `` 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`.

### `apt_prune`

`` 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`

`` Whether to remove APT (Advanced Packaging Tools) cache, include the local repository of retrieved package files.

### `chocolatey_enable`

**๐Ÿ”€{E}** `` 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`.

### `homebrew_enable`

**๐Ÿ”€{E}** `` 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`.

### `homebrew_prune`

`` 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`

`` Whether to remove Homebrew cache, include all of the:

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

### `npm_enable`

**๐Ÿ”€{E}** `` 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`.

### `npm_prune`

`` Whether to prune NPM (NodeJS Package Manager) all of the extraneous packages.

### `npm_clean`

`` Whether to remove NPM (NodeJS Package Manager) cache.

### `pipx_enable`

**๐Ÿ”€{E}** `` 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`.

### `wmic_enable`

**๐Ÿ”€{E}** `` 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`.

### `fs_enable`

**๐Ÿ”€{E}** `` Whether to optimize via file system.

If all of the inputs inside this switch group are `False`, this input will default to `True`.

### `os_swap`

`` Whether to remove system page/swap file.

## ๐Ÿงฉ Output

*N/A*

## โœ๏ธ Example

- ```yml
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"
```

## ๐Ÿ“š Guide

- GitHub Actions
- [Enabling debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging)