Skip to content

Commit c7470ce

Browse files
committed
ci: add GitHub action to clean up runner disk space
Define a composite action to remove large toolsets, unused packages, Docker images, and caches from the GitHub runner, freeing up disk space for builds. Note that this file is copied from the following `tapd` PR: lightninglabs/taproot-assets#1878 Not all of the targeted files when running the script, should ever have been used when building the binaries for LNC, but we keep the script consistent between the repos for simplicity.
1 parent 782a956 commit c7470ce

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Clean up runner disk space"
2+
description: "Removes large, non-essential toolsets to free up disk space on the runner."
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Free up disk space
8+
shell: bash
9+
run: |
10+
echo "Removing large toolsets to free up disk space..."
11+
echo "Disk space before cleanup:"
12+
df -h
13+
14+
# Remove dotnet to save disk space.
15+
sudo rm -rf /usr/share/dotnet
16+
# Remove android to save disk space.
17+
sudo rm -rf /usr/local/lib/android
18+
# Remove ghc to save disk space.
19+
sudo rm -rf /opt/ghc
20+
# Remove large packages.
21+
sudo rm -rf /usr/share/swift
22+
sudo rm -rf /usr/local/julia*
23+
sudo rm -rf /opt/hostedtoolcache
24+
25+
# Remove docker images to save space.
26+
docker image prune -a -f || true
27+
28+
# Remove large apt packages.
29+
sudo apt-get remove -y \
30+
'^aspnetcore-.*' \
31+
'^dotnet-.*' \
32+
'^llvm-.*' \
33+
'php.*' \
34+
'^mongodb-.*' \
35+
'^mysql-.*' \
36+
azure-cli \
37+
google-chrome-stable \
38+
firefox \
39+
powershell \
40+
mono-devel \
41+
libgl1-mesa-dri 2>/dev/null || true
42+
sudo apt-get autoremove -y
43+
sudo apt-get clean
44+
45+
# Remove caches.
46+
sudo rm -rf /usr/local/share/boost
47+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
48+
49+
echo "Disk space after cleanup:"
50+
df -h

0 commit comments

Comments
 (0)