Skip to content

Commit fd978fb

Browse files
feat: add more_space action (#21)
1 parent 6b4315e commit fd978fb

File tree

6 files changed

+947
-9
lines changed

6 files changed

+947
-9
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,27 @@ jobs:
130130
EOF
131131
132132
echo "Action outputs:"
133-
jq . outputs.json
133+
134+
# Process all keys in the JSON, attempting to parse each value as JSON
135+
jq 'to_entries | map(
136+
if (.value | type) == "string" then
137+
try (
138+
.value |= (fromjson)
139+
) catch (
140+
# If parsing fails, keep the original value
141+
.
142+
)
143+
else
144+
# If not a string, keep as-is
145+
.
146+
end
147+
) | from_entries' outputs.json || jq . outputs.json
134148
135149
- name: Run post-CI tests
136150
env:
137151
GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
138152
WITH_PARAMS: ${{ steps.process-with.outputs.with-params }}
153+
if: always() # make sure we do any cleanup even if the job was canceled or failed
139154
shell: bash
140155
run: |
141156
if [ -f ${{ matrix.action }}/post-ci.sh ]; then
@@ -144,3 +159,10 @@ jobs:
144159
else
145160
echo "No post-CI tests found for ${{ matrix.action }}"
146161
fi
162+
163+
conclude:
164+
runs-on: ubuntu-latest
165+
needs: test
166+
steps:
167+
- name: Conclude
168+
run: echo "All tests passed"

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ This is a monorepo containing a collection of GitHub Actions maintained by Lizar
77

88
## actions
99

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

1920
## Contributions
2021

actions/more_space/README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# more_space
2+
3+
A reusable action to free up GitHub hosted runner space by removing unnecessary files and components.
4+
5+
## Basic Usage
6+
7+
See [action.yml](action.yml)
8+
9+
```yaml
10+
steps:
11+
- name: Free Disk Space
12+
uses: LizardByte/actions/actions/more_space@master
13+
```
14+
15+
## Advanced Usage
16+
17+
```yaml
18+
steps:
19+
- name: Free Disk Space with Analysis
20+
uses: LizardByte/actions/actions/more_space@master
21+
with:
22+
analyze-space-savings: true
23+
clean-all: true
24+
safe-packages: "jq,git"
25+
```
26+
27+
## Inputs
28+
29+
| Name | Description | Default | Required |
30+
|-----------------------|----------------------------------------------------------------------------------------------|---------|----------|
31+
| analyze-space-savings | Generate detailed analysis of space savings by each input option | `false` | `false` |
32+
| clean-all | When true, all inputs except 'safe-packages' are ignored and all cleanup options are enabled | `false` | `false` |
33+
| safe-packages | A list of packages to keep. If found the cleanup step where found will be sipped | | `false` |
34+
| remove-android | Remove Android SDK | `false` | `false` |
35+
| remove-chocolatey | Remove Chocolatey (Windows only) | `false` | `false` |
36+
| remove-codeql | Remove CodeQL databases | `false` | `false` |
37+
| remove-docker-images | Remove Docker images | `false` | `false` |
38+
| remove-docs-linux | Remove /usr/share/doc (Linux only) | `false` | `false` |
39+
| remove-dotnet | Remove .NET runtime and tools | `false` | `false` |
40+
| remove-haskell | Remove Haskell | `false` | `false` |
41+
| remove-homebrew | Remove Homebrew (Linux/macOS only) | `false` | `false` |
42+
| remove-jvm | Remove JVMs | `false` | `false` |
43+
| remove-swift | Remove Swift (Linux/macOS only) | `false` | `false` |
44+
| remove-tool-cache | Remove runner tool cache | `false` | `false` |
45+
| remove-tools-windows | Remove /c/tools (Windows only) | `false` | `false` |
46+
| remove-xcode | Remove Xcode (macOS only) | `false` | `false` |
47+
48+
## Outputs
49+
50+
| Name | Description |
51+
|----------------|----------------------------------------------------------------------------------|
52+
| space-after | Free disk space after cleanup (GB) |
53+
| space-analysis | JSON formatted analysis of space savings by input option (sorted by space saved) |
54+
| space-before | Free disk space before cleanup (GB) |
55+
| space-saved | Amount of disk space saved (GB) |
56+
57+
## Expected Space Savings
58+
59+
The following table shows the expected space savings for each cleanup option across different runner types. Values are in GB.
60+
61+
| 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 |
62+
|------------------------|--------------|------------------|--------------|------------------|--------------|--------------|----------------|----------|----------|----------|
63+
| `remove-android` | 8.49 | - | 9.32 | - | FIX | FIX | FIX | 13.15 | 13.06 | 12.20 |
64+
| `remove-codeql` | 1.54 | - | 1.54 | - | 1.11 | 1.11 | 1.08 | 3.46 | 3.45 | 3.43 |
65+
| `remove-dotnet` | 1.10 | - | FIX | - | 10.04 | 4.18 | 12.88 | 3.82 | 4.02 | 4.01 |
66+
| `remove-docker-images` | 3.44 | 3.41 | 0.00 | 0.00 | 10.40 | 0.00 | - | - | - | - |
67+
| `remove-chocolatey` | - | - | - | - | 2.56 | 2.52 | 2.38 | - | - | - |
68+
| `remove-docs-linux` | 0.13 | 0.14 | 0.12 | 0.12 | - | - | - | - | - | - |
69+
| `remove-haskell` | 6.24 | - | 6.24 | - | 10.02 | 3.65 | - | TODO | TODO | TODO |
70+
| `remove-homebrew` | 0.18 | - | 0.18 | - | - | - | - | 1.65 | 7.36 | 7.84 |
71+
| `remove-jvm` | 1.14 | 1.14 | 1.13 | 1.14 | 1.10 | 1.10 | 0.58 | 1.08 | 0.91 | 0.92 |
72+
| `remove-swift` | 2.70 | 2.68 | 2.71 | 2.68 | - | - | - | 0.44 | 0.44 | 0.49 |
73+
| `remove-tool-cache` | 3.84 | - | 3.47 | - | 3.53 | 2.42 | 1.68 | 2.62 | 1.45 | 1.43 |
74+
| `remove-tools-windows` | - | - | - | - | 0.22 | 0.22 | 0.21 | - | - | - |
75+
| `remove-xcode` | - | - | - | - | - | - | - | 49.88 | 35.14 | 28.99 |
76+
| Linux package cleanup | 0.08 | 0.18 | 0.03 | 0.13 | - | - | - | - | - | - |
77+
| Total saved | 28.88 | 7.55 | 24.74 | 4.07 | 38.98 | 15.20 | 18.81 | 76.10 | 65.83 | 59.31 |
78+
79+
## Examples
80+
81+
### Clean Everything
82+
83+
```yaml
84+
- name: Free Maximum Disk Space
85+
uses: LizardByte/actions/actions/more_space@master
86+
with:
87+
clean-all: true
88+
```
89+
90+
### Target Specific Components
91+
92+
```yaml
93+
- name: Free Disk Space for Container Build
94+
uses: LizardByte/actions/actions/more_space@master
95+
with:
96+
remove-docker-images: true
97+
remove-dotnet: true
98+
remove-android: true
99+
```
100+
101+
### Analyze Space Usage
102+
103+
```yaml
104+
- name: Analyze Disk Space Usage
105+
uses: LizardByte/actions/actions/more_space@master
106+
with:
107+
analyze-space-savings: true
108+
clean-all: true
109+
110+
- name: Display Analysis
111+
run: echo '${{ steps.cleanup.outputs.space-analysis }}'
112+
```
113+
114+
## Safe Package Protection
115+
116+
When using `safe-packages`, the action will:
117+
118+
1. Locate the specified packages using system commands (`which`, `where`)
119+
2. Check if any cleanup target contains these packages
120+
3. Skip removal of directories containing protected packages
121+
4. Continue with other cleanup operations
122+
123+
This ensures critical tools remain available after cleanup.

actions/more_space/action.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
name: "More space"
3+
description: "A reusable action to free up GitHub hosted runner space."
4+
author: "LizardByte"
5+
6+
branding:
7+
icon: hard-drive
8+
color: green
9+
10+
inputs:
11+
analyze-space-savings:
12+
description: "Generate detailed analysis of space savings by each input option"
13+
required: false
14+
default: "false"
15+
clean-all:
16+
description: "When true, all inputs except 'safe_packages' are ignored"
17+
required: false
18+
default: "false"
19+
safe-packages:
20+
description: "A list of packages to keep. The action will try to find the location of these and preserve them."
21+
required: false
22+
default: ""
23+
remove-android:
24+
description: "Remove Android SDK"
25+
required: false
26+
default: "false"
27+
remove-chocolatey:
28+
description: "Remove Chocolatey (Windows only)"
29+
required: false
30+
default: "false"
31+
remove-codeql:
32+
description: "Remove CodeQL databases"
33+
required: false
34+
default: "false"
35+
remove-docker-images:
36+
description: "Remove Docker images"
37+
required: false
38+
default: "false"
39+
remove-docs-linux:
40+
description: "Remove /usr/share/doc (Linux only)"
41+
required: false
42+
default: "false"
43+
remove-dotnet:
44+
description: "Remove .NET runtime and tools"
45+
required: false
46+
default: "false"
47+
remove-haskell:
48+
description: "Remove Haskell"
49+
required: false
50+
default: "false"
51+
remove-homebrew:
52+
description: "Remove Homebrew (Linux/macOS only)"
53+
required: false
54+
default: "false"
55+
remove-jvm:
56+
description: "Remove JVMs"
57+
required: false
58+
default: "false"
59+
remove-swift:
60+
description: "Remove Swift (Linux/macOS only)"
61+
required: false
62+
default: "false"
63+
remove-tool-cache:
64+
description: "Remove runner tool cache"
65+
required: false
66+
default: "false"
67+
remove-tools-windows:
68+
description: "Remove /c/tools (Windows only)"
69+
required: false
70+
default: "false"
71+
remove-xcode:
72+
description: "Remove Xcode (macOS only)"
73+
required: false
74+
default: "false"
75+
76+
outputs:
77+
space-after:
78+
description: "Free disk space after cleanup (GB)"
79+
value: ${{ steps.cleanup.outputs.space-after }}
80+
space-analysis:
81+
description: "JSON formatted analysis of space savings by input option (sorted by space saved)"
82+
value: ${{ steps.cleanup.outputs.space-analysis }}
83+
space-before:
84+
description: "Free disk space before cleanup (GB)"
85+
value: ${{ steps.cleanup.outputs.space-before }}
86+
space-saved:
87+
description: "Amount of disk space saved (GB)"
88+
value: ${{ steps.cleanup.outputs.space-saved }}
89+
90+
runs:
91+
using: "composite"
92+
steps:
93+
- run: which jq
94+
shell: bash
95+
96+
- name: Make cleanup script executable
97+
shell: bash
98+
run: chmod +x "${{ github.action_path }}/cleanup.sh"
99+
100+
- name: Free up disk space
101+
id: cleanup
102+
shell: bash
103+
run: |
104+
"${{ github.action_path }}/cleanup.sh" \
105+
--analyze-space-savings="${{ inputs.analyze-space-savings }}" \
106+
--clean-all="${{ inputs.clean-all }}" \
107+
--remove-android="${{ inputs.remove-android }}" \
108+
--remove-chocolatey="${{ inputs.remove-chocolatey }}" \
109+
--remove-codeql="${{ inputs.remove-codeql }}" \
110+
--remove-docker-images="${{ inputs.remove-docker-images }}" \
111+
--remove-docs-linux="${{ inputs.remove-docs-linux }}" \
112+
--remove-dotnet="${{ inputs.remove-dotnet }}" \
113+
--remove-haskell="${{ inputs.remove-haskell }}" \
114+
--remove-homebrew="${{ inputs.remove-homebrew }}" \
115+
--remove-jvm="${{ inputs.remove-jvm }}" \
116+
--remove-swift="${{ inputs.remove-swift }}" \
117+
--remove-tool-cache="${{ inputs.remove-tool-cache }}" \
118+
--remove-tools-windows="${{ inputs.remove-tools-windows }}" \
119+
--remove-xcode="${{ inputs.remove-xcode }}" \
120+
--safe-packages="${{ inputs.safe-packages }}"

actions/more_space/ci-matrix.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[
2+
{
3+
"runs-on": "macos-13",
4+
"with": {
5+
"analyze-space-savings": true,
6+
"clean-all": true
7+
}
8+
},
9+
{
10+
"runs-on": "macos-14",
11+
"with": {
12+
"analyze-space-savings": true,
13+
"clean-all": true,
14+
"safe-packages": "jq"
15+
}
16+
},
17+
{
18+
"runs-on": "macos-15",
19+
"with": {
20+
"analyze-space-savings": true,
21+
"clean-all": true
22+
}
23+
},
24+
{
25+
"runs-on": "windows-2022",
26+
"with": {
27+
"analyze-space-savings": true,
28+
"clean-all": true,
29+
"safe-packages": "jq"
30+
}
31+
},
32+
{
33+
"runs-on": "windows-2025",
34+
"with": {
35+
"analyze-space-savings": true,
36+
"clean-all": true,
37+
"safe-packages": "jq"
38+
}
39+
},
40+
{
41+
"runs-on": "windows-11-arm",
42+
"with": {
43+
"analyze-space-savings": true,
44+
"clean-all": true,
45+
"safe-packages": "jq"
46+
}
47+
},
48+
{
49+
"runs-on": "ubuntu-22.04",
50+
"with": {
51+
"analyze-space-savings": true,
52+
"clean-all": true
53+
}
54+
},
55+
{
56+
"runs-on": "ubuntu-22.04-arm",
57+
"with": {
58+
"analyze-space-savings": true,
59+
"clean-all": true
60+
}
61+
},
62+
{
63+
"runs-on": "ubuntu-24.04",
64+
"with": {
65+
"analyze-space-savings": true,
66+
"clean-all": true
67+
}
68+
},
69+
{
70+
"runs-on": "ubuntu-24.04-arm",
71+
"with": {
72+
"analyze-space-savings": true,
73+
"clean-all": true
74+
}
75+
}
76+
]

0 commit comments

Comments
 (0)