Skip to content

Commit 07c0dfc

Browse files
authored
Clear disk space before release (#10775)
Signed-off-by: Jenny Shu <[email protected]>
1 parent 1cf50fd commit 07c0dfc

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

.github/actions/prep-go-runner/action.yaml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,45 @@ runs:
2020
run: |
2121
echo "Before clearing disk space:"
2222
df -h
23+
docker system df -v
2324
24-
# https://github.com/actions/virtual-environments/issues/709
25-
sudo apt-get clean
26-
25+
# https://github.com/actions/runner-images/discussions/3242 github runners are bad at cleanup
26+
echo "Removing large packages"
27+
sudo apt-get remove -y '^dotnet-.*' || true
28+
sudo apt-get remove -y '^llvm-.*' || true
29+
sudo apt-get remove -y 'php.*' || true
30+
sudo apt-get remove -y '^mongodb-.*' || true
31+
sudo apt-get remove -y '^mysql-.*' || true
32+
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true
33+
sudo apt-get autoremove -y || true
34+
sudo apt-get clean -y || true
35+
echo "Done removing large packages"
36+
2737
# Clean up pre-installed tools
28-
# https://github.com/actions/virtual-environments/issues/1918
29-
sudo rm -rf /usr/share/dotnet
30-
sudo rm -rf /opt/ghc
31-
sudo rm -rf /usr/local/share/boost
32-
sudo rm -rf $AGENT_TOOLSDIRECTORY
38+
sudo rm -rf /usr/local/lib/android || true
39+
sudo rm -rf /usr/share/dotnet || true
40+
sudo rm -rf /usr/local/graalvm || true
41+
sudo rm -rf /opt/ghc || true
42+
sudo rm -rf /usr/local/.ghcup || true
43+
sudo rm -rf /usr/local/share/boost || true
44+
sudo rm -rf /usr/local/share/powershell || true
45+
sudo rm -rf /usr/local/share/chromium || true
46+
sudo rm -rf $AGENT_TOOLSDIRECTORY || true
47+
48+
# Clean up images
49+
docker image rm node:16 || true
50+
docker image rm node:16-alpine || true
51+
docker image rm node:18 || true
52+
docker image rm node:18-alpine || true
53+
docker image rm node:20 || true
54+
docker image rm node:20-alpine || true
55+
# remove the dangling images and containers
56+
docker images | tail -n +2 | awk '$1 == "<none>" {print $3}' | xargs --no-run-if-empty docker rmi
57+
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $1}' | xargs --no-run-if-empty docker rm --volumes=true
3358
3459
echo "After clearing disk space:"
3560
df -h
61+
docker system df -v
3662
- name: Set up Go
3763
id: setup-go
3864
uses: actions/setup-go@v5

.github/workflows/release.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
- uses: actions/checkout@v4
4040
with:
4141
fetch-depth: 0
42-
4342
- name: Set the release related variables
4443
id: set_vars
4544
run: |
@@ -79,6 +78,9 @@ jobs:
7978
steps:
8079
- uses: actions/checkout@v4
8180

81+
- name: Prep Go Runner
82+
uses: ./.github/actions/prep-go-runner
83+
8284
- name: Helm login to ${{ env.IMAGE_REGISTRY }}
8385
if: ${{ github.event_name != 'pull_request' }}
8486
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.IMAGE_REGISTRY }} -u ${{ github.repository_owner }} --password-stdin
@@ -105,11 +107,8 @@ jobs:
105107
- uses: actions/checkout@v4
106108
with:
107109
fetch-depth: 0
108-
109-
- uses: actions/setup-go@v5
110-
with:
111-
go-version-file: "go.mod"
112-
cache: true
110+
- name: Prep Go Runner
111+
uses: ./.github/actions/prep-go-runner
113112

114113
# We publish a rolling main release for every commit to main. Deleting the release
115114
# ensures that the tagged commit is not stale. Goreleaser will create a new tag
@@ -151,10 +150,8 @@ jobs:
151150
runs-on: ubuntu-22.04
152151
steps:
153152
- uses: actions/checkout@v4
154-
155-
- uses: actions/setup-go@v5
156-
with:
157-
go-version-file: "go.mod"
153+
- name: Prep Go Runner
154+
uses: ./.github/actions/prep-go-runner
158155

159156
- name: Login to ghcr.io
160157
if: ${{ github.event_name != 'pull_request' }}

0 commit comments

Comments
 (0)