Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 258ccab

Browse files
Added clean-disk-ubuntu action
1 parent ae03424 commit 258ccab

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,16 @@ Example:
186186
golden-image-mode: compare_update
187187
non-separable-progs: false
188188
```
189+
190+
191+
## clean-disk-ubuntu
192+
193+
Removes unneeded packages and tools to free disk space.
194+
195+
Example:
196+
197+
```yml
198+
- name: Clean Disk
199+
uses: DiligentGraphics/github-action/clean-disk-ubuntu@master
200+
preserve-android-ndk: 27.0.12077973
201+
```

clean-disk-ubuntu/action.yml

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: "DiligentGraphics: Clean Disk Space"
2+
description: "Remove unneeded packages and tools to free disk space"
3+
4+
inputs:
5+
preserve-android-ndk:
6+
description: Android NDK version to preserve
7+
required: false
8+
default: "27.0.12077973"
9+
10+
runs:
11+
using: "composite" # must be set to "composite"
12+
13+
steps:
14+
- name: Available disk space
15+
shell: bash
16+
run: |
17+
# Available disk space
18+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
19+
20+
- name: Remove .NET
21+
shell: bash
22+
run: |
23+
# Remove .NET
24+
sudo rm -rf /usr/share/dotnet || echo "::warning::Failed to remove .NET"
25+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
26+
27+
- name: Remove Swift
28+
shell: bash
29+
run: |
30+
# Remove Swift
31+
sudo rm -rf /usr/share/swift || echo "::warning::Failed to remove Swift"
32+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
33+
34+
- name: Remove CodeQL Action Bundles
35+
shell: bash
36+
run: |
37+
# Remove CodeQL Action Bundles
38+
sudo rm -rf /opt/hostedtoolcache/CodeQL || echo "::warning::Failed to remove CodeQL Action Bundles"
39+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
40+
41+
- name: Remove image tool cache
42+
shell: bash
43+
run: |
44+
# Remove image tool cache
45+
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || echo "::warning::Failed to remove image tool cache"
46+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
47+
48+
- name: Remove unused Android NDKs
49+
shell: bash
50+
run: |
51+
# Remove unused Android NDKs
52+
ANDROID_NDK_DIR=/usr/local/lib/android/sdk/ndk
53+
echo "Current NDKs:"
54+
ls $ANDROID_NDK_DIR
55+
for dir in $ANDROID_NDK_DIR/* ; do
56+
if [ "${dir%/}" != "$ANDROID_NDK_DIR/${{ inputs.preserve-android-ndk }}" ]; then
57+
rm -rf "$dir"
58+
fi
59+
done
60+
echo "Remaining NDKs:"
61+
ls $ANDROID_NDK_DIR
62+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
63+
64+
- name: Remove cached Docker images
65+
shell: bash
66+
run: |
67+
# Remove cached Docker images
68+
sudo docker image prune --all --force || echo "::warning::Failed to remove Docker images"
69+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
70+
71+
- name: Remove ASP.NET Core
72+
shell: bash
73+
run: |
74+
# Remove ASP.NET Core
75+
sudo apt-get remove -y '^aspnetcore-.*' --fix-missing || echo "::warning::Failed to remove ASP.NET Core"
76+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
77+
78+
- name: Remove Azure CLI
79+
shell: bash
80+
run: |
81+
# Remove Azure CLI
82+
sudo apt-get remove -y azure-cli --fix-missing || echo "::warning::Failed to remove Azure CLI"
83+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
84+
85+
- name: Remove Chrome and Firefox
86+
shell: bash
87+
run: |
88+
# Remove Chrome and Firefox
89+
sudo apt-get remove -y google-chrome-stable firefox --fix-missing || echo "::warning::Failed to remove Chrome and Firefox"
90+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
91+
92+
- name: APT Cleanup
93+
shell: bash
94+
run: |
95+
# APT Cleanup
96+
sudo apt-get autoremove -y || echo "::warning::Failed to remove unneeded packages"
97+
sudo apt-get clean || echo "::warning::Failed to clean up"
98+
echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n "
99+
100+
- name: Disk space after cleanup
101+
shell: bash
102+
run: |
103+
# Disk space after cleanup
104+
df -h

0 commit comments

Comments
 (0)