Skip to content

Commit 307349f

Browse files
authored
Merge pull request #15 from lsst-sqre/u/ajt/freespace
Add flag to free up space on the GHA Runner
2 parents 9b4fd62 + 2e5c7f4 commit 307349f

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

.github/workflows/build.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ on:
2222
default: "."
2323
type: string
2424
cache:
25-
description: "Whether to use GitHub cache for images. If they are very large, you might not want to."
25+
description: "Whether to use GitHub cache for images. Since the caches are not keyed by platform, they do not work well anyway (hence the default)."
2626
required: false
2727
default: false
2828
type: boolean
@@ -49,6 +49,11 @@ on:
4949
required: false
5050
type: number
5151
default: 1
52+
free-space:
53+
description: "Free space on GitHub runner."
54+
required: false
55+
type: boolean
56+
default: false
5257
outputs:
5358
tag:
5459
description: "The tag that was used for the built image"
@@ -118,6 +123,24 @@ jobs:
118123
- arch: "arm64"
119124
runs_on: "ubuntu-24.04-arm"
120125
steps:
126+
- name: Free space
127+
if: ${{ inputs.free-space }}
128+
shell: bash
129+
run: |
130+
set -euo pipefail
131+
echo "Free disk space (start)"
132+
df -ah
133+
echo "Removing .NET"
134+
sudo rm -rf /usr/share/dotnet
135+
echo "Removing Android SDK"
136+
sudo rm -rf /usr/local/lib/android
137+
echo "Removing Haskell"
138+
sudo rm -rf /opt/ghc
139+
echo "Removing CodeQL"
140+
sudo rm -rf /opt/hostedtoolcache/CodeQL
141+
echo "Free disk space (end)"
142+
df -ah
143+
121144
- name: Checkout source
122145
uses: actions/checkout@v5
123146
with:

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,17 @@ RUN --mount=type=secret,id=NPM_TOKEN \
113113
If `true`, the action uses the built-in GitHub Actions cache to to store Docker build layers between runs.
114114
However, this cache appears to have a race condition when used across multiple architectures so that only one architecture is effectively cached.
115115
Disabling caching altogether at least avoids the time cost of uploading and downloading the cache.
116-
If the image being built is very large, `false` might be preferable, as the total cache size is 10GB as of October 2025.
117116

118117
- `push` (boolean, optional) a flag to enable pushing to artifact registries (based on the `image` input) .
119118
Default is `true`.
120119
If `false`, the action skips the image push, but still builds the image with [`docker build`](https://docs.docker.com/engine/reference/commandline/build/).
121120
In that case the action does not perform the manifest reassembly across platforms.
122121

122+
- `free-space` (boolean, optional) a flag to remove the .NET, Android SDK, Haskell, and CodeQL directories.
123+
If your builds are running out of space, try this.
124+
Default is `false`.
125+
This saves 18GB on amd64 (only 3GB on arm64).
126+
123127
- `target` (string, optional) the name of a build stage in the Dockerfile to target for the image. This allows multiple images built from a single Dockerfile, e.g., "runtime-A" and "runtime-B".
124128

125129
- `fetch-depth` (number, optional) the git checkout fetch-depth. Set to 0 for complete history, which some builds require.

0 commit comments

Comments
 (0)