Skip to content

Commit 8d9dea3

Browse files
committed
Free up disk spaces
Signed-off-by: Yuki Iwai <[email protected]>
1 parent 9c64003 commit 8d9dea3

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Free-Up Disk Space
2+
description: Remove Non-Essential Tools And Move Docker Data Directory to /mnt/docker
3+
4+
runs:
5+
using: composite
6+
steps:
7+
# This step is a Workaround to avoid the "No space left on device" error.
8+
# ref: https://github.com/actions/runner-images/issues/2840
9+
- name: Remove unnecessary files
10+
shell: bash
11+
run: |
12+
echo "Disk usage before cleanup:"
13+
df -hT
14+
15+
sudo rm -rf /usr/share/dotnet
16+
sudo rm -rf /opt/ghc
17+
sudo rm -rf /usr/local/share/boost
18+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
19+
sudo rm -rf /usr/local/lib/android
20+
sudo rm -rf /usr/local/share/powershell
21+
sudo rm -rf /usr/share/swift
22+
23+
echo "Disk usage after cleanup:"
24+
df -hT
25+
26+
- name: Prune docker images
27+
shell: bash
28+
run: |
29+
docker image prune -a -f
30+
docker system df
31+
df -hT
32+
33+
- name: Move docker data directory
34+
shell: bash
35+
run: |
36+
echo "Stopping docker service ..."
37+
sudo systemctl stop docker
38+
DOCKER_DEFAULT_ROOT_DIR=/var/lib/docker
39+
DOCKER_ROOT_DIR=/mnt/docker
40+
echo "Moving ${DOCKER_DEFAULT_ROOT_DIR} -> ${DOCKER_ROOT_DIR}"
41+
sudo mv ${DOCKER_DEFAULT_ROOT_DIR} ${DOCKER_ROOT_DIR}
42+
echo "Creating symlink ${DOCKER_DEFAULT_ROOT_DIR} -> ${DOCKER_ROOT_DIR}"
43+
sudo ln -s ${DOCKER_ROOT_DIR} ${DOCKER_DEFAULT_ROOT_DIR}
44+
echo "$(sudo ls -l ${DOCKER_DEFAULT_ROOT_DIR})"
45+
echo "Starting docker service ..."
46+
sudo systemctl daemon-reload
47+
sudo systemctl start docker
48+
echo "Docker service status:"
49+
sudo systemctl --no-pager -l -o short status docker

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
steps:
4343
- name: Clone the code
4444
uses: actions/checkout@v3
45+
- name: Free-up Disk Space
46+
uses: ./.github/workflows/free-up-disk-space
4547
- name: Setup Go
4648
uses: actions/setup-go@v3
4749
with:

0 commit comments

Comments
 (0)