Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,27 @@ jobs:
EOF

echo "Action outputs:"
jq . outputs.json

# Process all keys in the JSON, attempting to parse each value as JSON
jq 'to_entries | map(
if (.value | type) == "string" then
try (
.value |= (fromjson)
) catch (
# If parsing fails, keep the original value
.
)
else
# If not a string, keep as-is
.
end
) | from_entries' outputs.json || jq . outputs.json

- name: Run post-CI tests
env:
GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
WITH_PARAMS: ${{ steps.process-with.outputs.with-params }}
if: always() # make sure we do any cleanup even if the job was canceled or failed
shell: bash
run: |
if [ -f ${{ matrix.action }}/post-ci.sh ]; then
Expand All @@ -144,3 +159,10 @@ jobs:
else
echo "No post-CI tests found for ${{ matrix.action }}"
fi

conclude:
runs-on: ubuntu-latest
needs: test
steps:
- name: Conclude
run: echo "All tests passed"
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ This is a monorepo containing a collection of GitHub Actions maintained by Lizar

## actions

| Action | Description | Type | Language |
|-------------------------------------------------------|---------------------------------------------|-----------|------------------|
| [facebook_post](actions/facebook_post#readme) | Post to Facebook page/group using Graph API | docker | python |
| [release_changelog](actions/release_changelog#readme) | Generate a changelog for the latest release | composite | javascript |
| [release_create](actions/release_create#readme) | Create a new release | composite | bash, javascript |
| [release_homebrew](actions/release_homebrew#readme) | Validate and update Homebrew formula | composite | bash, python |
| [release_setup](actions/release_setup#readme) | Prepare a release | docker | python |
| [setup_python](actions/setup_python#readme) | Set up Python environment | composite | bash |
| Action | Description | Type | Language |
|-------------------------------------------------------|----------------------------------------------|-----------|------------------|
| [facebook_post](actions/facebook_post#readme) | Post to Facebook page/group using Graph API | docker | python |
| [more_space](actions/more_space#readme) | Free up disk space in GitHub Actions runners | composite | bash |
| [release_changelog](actions/release_changelog#readme) | Generate a changelog for the latest release | composite | javascript |
| [release_create](actions/release_create#readme) | Create a new release | composite | bash, javascript |
| [release_homebrew](actions/release_homebrew#readme) | Validate and update Homebrew formula | composite | bash, python |
| [release_setup](actions/release_setup#readme) | Prepare a release | docker | python |
| [setup_python](actions/setup_python#readme) | Set up Python environment | composite | bash |

## Contributions

Expand Down
123 changes: 123 additions & 0 deletions actions/more_space/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# more_space

A reusable action to free up GitHub hosted runner space by removing unnecessary files and components.

## Basic Usage

See [action.yml](action.yml)

```yaml
steps:
- name: Free Disk Space
uses: LizardByte/actions/actions/more_space@master
```

## Advanced Usage

```yaml
steps:
- name: Free Disk Space with Analysis
uses: LizardByte/actions/actions/more_space@master
with:
analyze-space-savings: true
clean-all: true
safe-packages: "jq,git"
```

## Inputs

| Name | Description | Default | Required |
|-----------------------|----------------------------------------------------------------------------------------------|---------|----------|
| analyze-space-savings | Generate detailed analysis of space savings by each input option | `false` | `false` |
| clean-all | When true, all inputs except 'safe-packages' are ignored and all cleanup options are enabled | `false` | `false` |
| safe-packages | A list of packages to keep. If found the cleanup step where found will be sipped | | `false` |
| remove-android | Remove Android SDK | `false` | `false` |
| remove-chocolatey | Remove Chocolatey (Windows only) | `false` | `false` |
| remove-codeql | Remove CodeQL databases | `false` | `false` |
| remove-docker-images | Remove Docker images | `false` | `false` |
| remove-docs-linux | Remove /usr/share/doc (Linux only) | `false` | `false` |
| remove-dotnet | Remove .NET runtime and tools | `false` | `false` |
| remove-haskell | Remove Haskell | `false` | `false` |
| remove-homebrew | Remove Homebrew (Linux/macOS only) | `false` | `false` |
| remove-jvm | Remove JVMs | `false` | `false` |
| remove-swift | Remove Swift (Linux/macOS only) | `false` | `false` |
| remove-tool-cache | Remove runner tool cache | `false` | `false` |
| remove-tools-windows | Remove /c/tools (Windows only) | `false` | `false` |
| remove-xcode | Remove Xcode (macOS only) | `false` | `false` |

## Outputs

| Name | Description |
|----------------|----------------------------------------------------------------------------------|
| space-after | Free disk space after cleanup (GB) |
| space-analysis | JSON formatted analysis of space savings by input option (sorted by space saved) |
| space-before | Free disk space before cleanup (GB) |
| space-saved | Amount of disk space saved (GB) |

## Expected Space Savings

The following table shows the expected space savings for each cleanup option across different runner types. Values are in GB.

| Input Option | ubuntu-22.04 | ubuntu-22.04-arm | ubuntu-24.04 | ubuntu-24.04-arm | windows-2022 | windows-2025 | windows-11-arm | macos-13 | macos-14 | macos-15 |
|------------------------|--------------|------------------|--------------|------------------|--------------|--------------|----------------|----------|----------|----------|
| `remove-android` | 8.49 | - | 9.32 | - | FIX | FIX | FIX | 13.15 | 13.06 | 12.20 |
| `remove-codeql` | 1.54 | - | 1.54 | - | 1.11 | 1.11 | 1.08 | 3.46 | 3.45 | 3.43 |
| `remove-dotnet` | 1.10 | - | FIX | - | 10.04 | 4.18 | 12.88 | 3.82 | 4.02 | 4.01 |
| `remove-docker-images` | 3.44 | 3.41 | 0.00 | 0.00 | 10.40 | 0.00 | - | - | - | - |
| `remove-chocolatey` | - | - | - | - | 2.56 | 2.52 | 2.38 | - | - | - |
| `remove-docs-linux` | 0.13 | 0.14 | 0.12 | 0.12 | - | - | - | - | - | - |
| `remove-haskell` | 6.24 | - | 6.24 | - | 10.02 | 3.65 | - | TODO | TODO | TODO |
| `remove-homebrew` | 0.18 | - | 0.18 | - | - | - | - | 1.65 | 7.36 | 7.84 |
| `remove-jvm` | 1.14 | 1.14 | 1.13 | 1.14 | 1.10 | 1.10 | 0.58 | 1.08 | 0.91 | 0.92 |
| `remove-swift` | 2.70 | 2.68 | 2.71 | 2.68 | - | - | - | 0.44 | 0.44 | 0.49 |
| `remove-tool-cache` | 3.84 | - | 3.47 | - | 3.53 | 2.42 | 1.68 | 2.62 | 1.45 | 1.43 |
| `remove-tools-windows` | - | - | - | - | 0.22 | 0.22 | 0.21 | - | - | - |
| `remove-xcode` | - | - | - | - | - | - | - | 49.88 | 35.14 | 28.99 |
| Linux package cleanup | 0.08 | 0.18 | 0.03 | 0.13 | - | - | - | - | - | - |
| Total saved | 28.88 | 7.55 | 24.74 | 4.07 | 38.98 | 15.20 | 18.81 | 76.10 | 65.83 | 59.31 |

## Examples

### Clean Everything

```yaml
- name: Free Maximum Disk Space
uses: LizardByte/actions/actions/more_space@master
with:
clean-all: true
```

### Target Specific Components

```yaml
- name: Free Disk Space for Container Build
uses: LizardByte/actions/actions/more_space@master
with:
remove-docker-images: true
remove-dotnet: true
remove-android: true
```

### Analyze Space Usage

```yaml
- name: Analyze Disk Space Usage
uses: LizardByte/actions/actions/more_space@master
with:
analyze-space-savings: true
clean-all: true

- name: Display Analysis
run: echo '${{ steps.cleanup.outputs.space-analysis }}'
```

## Safe Package Protection

When using `safe-packages`, the action will:

1. Locate the specified packages using system commands (`which`, `where`)
2. Check if any cleanup target contains these packages
3. Skip removal of directories containing protected packages
4. Continue with other cleanup operations

This ensures critical tools remain available after cleanup.
120 changes: 120 additions & 0 deletions actions/more_space/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
name: "More space"
description: "A reusable action to free up GitHub hosted runner space."
author: "LizardByte"

branding:
icon: hard-drive
color: green

inputs:
analyze-space-savings:
description: "Generate detailed analysis of space savings by each input option"
required: false
default: "false"
clean-all:
description: "When true, all inputs except 'safe_packages' are ignored"
required: false
default: "false"
safe-packages:
description: "A list of packages to keep. The action will try to find the location of these and preserve them."
required: false
default: ""
remove-android:
description: "Remove Android SDK"
required: false
default: "false"
remove-chocolatey:
description: "Remove Chocolatey (Windows only)"
required: false
default: "false"
remove-codeql:
description: "Remove CodeQL databases"
required: false
default: "false"
remove-docker-images:
description: "Remove Docker images"
required: false
default: "false"
remove-docs-linux:
description: "Remove /usr/share/doc (Linux only)"
required: false
default: "false"
remove-dotnet:
description: "Remove .NET runtime and tools"
required: false
default: "false"
remove-haskell:
description: "Remove Haskell"
required: false
default: "false"
remove-homebrew:
description: "Remove Homebrew (Linux/macOS only)"
required: false
default: "false"
remove-jvm:
description: "Remove JVMs"
required: false
default: "false"
remove-swift:
description: "Remove Swift (Linux/macOS only)"
required: false
default: "false"
remove-tool-cache:
description: "Remove runner tool cache"
required: false
default: "false"
remove-tools-windows:
description: "Remove /c/tools (Windows only)"
required: false
default: "false"
remove-xcode:
description: "Remove Xcode (macOS only)"
required: false
default: "false"

outputs:
space-after:
description: "Free disk space after cleanup (GB)"
value: ${{ steps.cleanup.outputs.space-after }}
space-analysis:
description: "JSON formatted analysis of space savings by input option (sorted by space saved)"
value: ${{ steps.cleanup.outputs.space-analysis }}
space-before:
description: "Free disk space before cleanup (GB)"
value: ${{ steps.cleanup.outputs.space-before }}
space-saved:
description: "Amount of disk space saved (GB)"
value: ${{ steps.cleanup.outputs.space-saved }}

runs:
using: "composite"
steps:
- run: which jq
shell: bash

- name: Make cleanup script executable
shell: bash
run: chmod +x "${{ github.action_path }}/cleanup.sh"

- name: Free up disk space
id: cleanup
shell: bash
run: |
"${{ github.action_path }}/cleanup.sh" \
--analyze-space-savings="${{ inputs.analyze-space-savings }}" \
--clean-all="${{ inputs.clean-all }}" \
--remove-android="${{ inputs.remove-android }}" \
--remove-chocolatey="${{ inputs.remove-chocolatey }}" \
--remove-codeql="${{ inputs.remove-codeql }}" \
--remove-docker-images="${{ inputs.remove-docker-images }}" \
--remove-docs-linux="${{ inputs.remove-docs-linux }}" \
--remove-dotnet="${{ inputs.remove-dotnet }}" \
--remove-haskell="${{ inputs.remove-haskell }}" \
--remove-homebrew="${{ inputs.remove-homebrew }}" \
--remove-jvm="${{ inputs.remove-jvm }}" \
--remove-swift="${{ inputs.remove-swift }}" \
--remove-tool-cache="${{ inputs.remove-tool-cache }}" \
--remove-tools-windows="${{ inputs.remove-tools-windows }}" \
--remove-xcode="${{ inputs.remove-xcode }}" \
--safe-packages="${{ inputs.safe-packages }}"
76 changes: 76 additions & 0 deletions actions/more_space/ci-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[
{
"runs-on": "macos-13",
"with": {
"analyze-space-savings": true,
"clean-all": true
}
},
{
"runs-on": "macos-14",
"with": {
"analyze-space-savings": true,
"clean-all": true,
"safe-packages": "jq"
}
},
{
"runs-on": "macos-15",
"with": {
"analyze-space-savings": true,
"clean-all": true
}
},
{
"runs-on": "windows-2022",
"with": {
"analyze-space-savings": true,
"clean-all": true,
"safe-packages": "jq"
}
},
{
"runs-on": "windows-2025",
"with": {
"analyze-space-savings": true,
"clean-all": true,
"safe-packages": "jq"
}
},
{
"runs-on": "windows-11-arm",
"with": {
"analyze-space-savings": true,
"clean-all": true,
"safe-packages": "jq"
}
},
{
"runs-on": "ubuntu-22.04",
"with": {
"analyze-space-savings": true,
"clean-all": true
}
},
{
"runs-on": "ubuntu-22.04-arm",
"with": {
"analyze-space-savings": true,
"clean-all": true
}
},
{
"runs-on": "ubuntu-24.04",
"with": {
"analyze-space-savings": true,
"clean-all": true
}
},
{
"runs-on": "ubuntu-24.04-arm",
"with": {
"analyze-space-savings": true,
"clean-all": true
}
}
]
Loading
Loading