Skip to content

Commit 166ce42

Browse files
authored
👷 Free up disk space (#105)
1 parent 7b4dfb5 commit 166ce42

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
14+
- name: "Free up disk space"
15+
uses: ./.github/actions/free-disk-space
1416
- name: Set up Python 3.11
1517
uses: actions/setup-python@v4
1618
with:

0 commit comments

Comments
 (0)