File tree Expand file tree Collapse file tree
actions/host-cleanup-linux Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Host Cleanup (Linux)
2+ description : Reclaims disk space on Linux CI agents by removing unused pre-installed software
3+
4+ runs :
5+ using : ' composite'
6+ steps :
7+ - name : Cleanup unused host dependencies
8+ if : runner.os == 'Linux'
9+ shell : bash
10+ 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 and non-interactive (no password prompt)
16+ if command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
17+ SUDO="sudo -n"
18+ else
19+ SUDO=""
20+ fi
21+
22+ echo "Disk space before cleanup:"
23+ df -h /
24+
25+ rm -rf ~/.cargo ~/.rustup ~/.dotnet || true
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+ if command -v snap >/dev/null 2>&1; then
36+ timeout 60s $SUDO snap remove lxd || true
37+ timeout 60s $SUDO snap remove core20 || true
38+ fi
39+
40+ if command -v apt-get >/dev/null 2>&1; then
41+ DEBIAN_FRONTEND=noninteractive timeout 120s $SUDO apt-get purge -y snapd || true
42+ fi
43+
44+ echo "Disk space after cleanup:"
45+ df -h /
Original file line number Diff line number Diff line change 8484 with :
8585 fetch-depth : 0
8686
87+ - name : Free disk space (Linux)
88+ uses : ./.github/actions/host-cleanup-linux
89+
8790 - name : Setup .NET
8891 uses : actions/setup-dotnet@v4
8992 with :
You can’t perform that action at this time.
0 commit comments