Skip to content

Commit 16eed0c

Browse files
committed
Try Joe's freeup-disk-space runner
1 parent 2b2b61d commit 16eed0c

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
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/image.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- name: Free disk space
14-
run: |
15-
sudo swapoff -a
16-
sudo rm -f /swapfile
17-
sudo apt clean
18-
if [ "$(docker image ls -q)" ]; then docker rmi $(docker image ls -aq); fi
19-
df -h
13+
- name: "Free up disk space"
14+
uses: ./.github/actions/free-up-disk-space
15+
# - name: Free disk space
16+
# run: |
17+
# sudo swapoff -a
18+
# sudo rm -f /swapfile
19+
# sudo apt clean
20+
# if [ "$(docker image ls -q)" ]; then docker rmi $(docker image ls -aq); fi
21+
# df -h
2022
- name: Build image
2123
run: |
2224
docker build -t fms-hf-tuning:dev . -f build/Dockerfile

0 commit comments

Comments
 (0)