Skip to content

Commit f4b5cf8

Browse files
committed
fix: align cleanup action with canonical org-wide pattern
- Use conditional sudo for container compatibility - Use apt-get purge instead of apt remove - Use rm -rf consistently - Add || true on all sudo lines for best-effort cleanup
1 parent fc94e84 commit f4b5cf8

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
1-
name: 'Host Cleanup (Linux)'
2-
description: 'Remove unused toolchains and SDKs to free disk space on Linux runners'
1+
name: Host Cleanup (Linux)
2+
description: Reclaims disk space on Linux CI agents by removing unused pre-installed software
33

44
runs:
55
using: 'composite'
66
steps:
7-
- name: Cleanup unused image dependencies
7+
- name: Cleanup unused host dependencies
88
if: runner.os == 'Linux'
99
shell: bash
1010
run: |
11+
# This list is based on what the base image contains and
12+
# may need to be adjusted as new software gets installed.
13+
# Use the `du` command to determine what can be uninstalled.
14+
15+
# Use sudo only when available (containers may not have it)
16+
if command -v sudo >/dev/null 2>&1; then
17+
SUDO="sudo"
18+
else
19+
SUDO=""
20+
fi
21+
1122
echo "Disk space before cleanup:"
1223
df -h /
13-
rm -fR ~/.cargo ~/.rustup ~/.dotnet
14-
sudo rm -fR /usr/share/swift /opt/microsoft/msedge /usr/local/.ghcup /usr/lib/mono /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
15-
sudo snap remove lxd || true
16-
sudo snap remove core20 || true
17-
sudo apt remove -y snapd || true
24+
25+
rm -rf ~/.cargo ~/.rustup ~/.dotnet
26+
27+
$SUDO rm -rf /usr/share/swift || true
28+
$SUDO rm -rf /opt/microsoft/msedge || true
29+
$SUDO rm -rf /usr/local/.ghcup || true
30+
$SUDO rm -rf /usr/lib/mono || true
31+
$SUDO rm -rf /usr/local/lib/android || true
32+
$SUDO rm -rf /opt/ghc || true
33+
$SUDO rm -rf /opt/hostedtoolcache/CodeQL || true
34+
35+
$SUDO snap remove lxd || true
36+
$SUDO snap remove core20 || true
37+
$SUDO apt-get purge -y snapd || true
38+
1839
echo "Disk space after cleanup:"
19-
df -h /
40+
df -h /

0 commit comments

Comments
 (0)