1+ name : " Free up disk space"
2+ description : " Removes non-essential tools, libraries and cached files from GitHub action runner node"
3+
4+ runs :
5+ using : " composite"
6+ steps :
7+ - name : " Remove non-essential tools and libraries"
8+ shell : bash
9+ run : |
10+ # https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
11+ echo "Disk usage before cleanup:"
12+ df -h
13+ echo "Removing non-essential tools and libraries ..."
14+ sudo rm -rf /opt/ghc
15+ sudo rm -rf /usr/local/.ghcup
16+ sudo rm -rf /usr/share/dotnet
17+ # sudo rm -rf /usr/local/share/boost
18+ echo "Deleting libraries for Android (12G), CodeQL (5.3G), PowerShell (1.3G), Swift (1.7G) ..."
19+ sudo rm -rf /usr/local/lib/android
20+ sudo rm -rf "${AGENT_TOOLSDIRECTORY}/CodeQL"
21+ sudo rm -rf /usr/local/share/powershell
22+ sudo rm -rf /usr/share/swift
23+ # ref: https://github.com/jlumbroso/free-disk-space/blob/main/action.yml
24+ echo "Deleting some larger apt packages:"
25+ sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..."
26+ sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..."
27+ sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..."
28+ sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..."
29+ sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..."
30+ sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..."
31+ sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..."
32+ sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..."
33+ sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..."
34+ sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..."
35+ sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."
36+ echo "Disk usage after cleanup:"
37+ df -h
38+
39+ - name : " Prune docker images"
40+ shell : bash
41+ run : |
42+ echo "Pruning docker images ..."
43+ docker image prune -a -f
44+ docker system df
45+ echo "Disk usage after pruning docker images:"
46+ df -h
0 commit comments