From 62aeb93b9da31a0803c77d7e3434b928b08a9ed9 Mon Sep 17 00:00:00 2001 From: Hongli Lai Date: Sun, 14 Jul 2024 17:39:18 +0200 Subject: [PATCH] Clean up more disk space during publishing --- .../ci-cd-publish-test-production.yml | 15 +++++++----- .../ci-cd-publish-test-production.yml.erb | 15 +++++++----- .github/workflows/ci-cd-publish-test-test.yml | 15 +++++++----- .../workflows/ci-cd-publish-test-test.yml.erb | 15 +++++++----- .../ci-cd/publish/clean-disk-space.sh | 23 +++++++++++++++++++ 5 files changed, 59 insertions(+), 24 deletions(-) create mode 100755 internal-scripts/ci-cd/publish/clean-disk-space.sh diff --git a/.github/workflows/ci-cd-publish-test-production.yml b/.github/workflows/ci-cd-publish-test-production.yml index 59b0049b..fd204c2e 100644 --- a/.github/workflows/ci-cd-publish-test-production.yml +++ b/.github/workflows/ci-cd-publish-test-production.yml @@ -78,8 +78,8 @@ jobs: publish: name: Publish packages - # Ubuntu 22.04 runner has more free disk space than 20.04 - runs-on: ubuntu-22.04 + # Ubuntu 24.04 runner has more free disk space than 22.04 + runs-on: ubuntu-24.04 environment: Production repos timeout-minutes: 30 permissions: @@ -87,9 +87,15 @@ jobs: needs: - determine_necessary_jobs steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Clean disk space + run: ./internal-scripts/ci-cd/publish/clean-disk-space.sh + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' - name: Login to Google Cloud uses: ./.github/actions/gcloud-login with: @@ -130,9 +136,6 @@ jobs: # Sets environment variable $LATEST_RELEASE_TAG run: ./internal-scripts/ci-cd/check-version-numbers-need-changing/determine-latest-release-tag.sh - - name: Free up disk space - run: sudo rm -rf /usr/share/dotnet "$AGENT_TOOLSDIRECTORY" - - name: Upload DEBs to repo run: ./internal-scripts/ci-cd/publish/publish-debs.rb pkgs/*/*.deb env: diff --git a/.github/workflows/ci-cd-publish-test-production.yml.erb b/.github/workflows/ci-cd-publish-test-production.yml.erb index a4acf5d1..d0a15127 100644 --- a/.github/workflows/ci-cd-publish-test-production.yml.erb +++ b/.github/workflows/ci-cd-publish-test-production.yml.erb @@ -68,8 +68,8 @@ jobs: publish: name: Publish packages - # Ubuntu 22.04 runner has more free disk space than 20.04 - runs-on: ubuntu-22.04 + # Ubuntu 24.04 runner has more free disk space than 22.04 + runs-on: ubuntu-24.04 environment: Production repos timeout-minutes: 30 permissions: @@ -77,9 +77,15 @@ jobs: needs: - determine_necessary_jobs steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Clean disk space + run: ./internal-scripts/ci-cd/publish/clean-disk-space.sh + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' - name: Login to Google Cloud uses: ./.github/actions/gcloud-login with: @@ -120,9 +126,6 @@ jobs: # Sets environment variable $LATEST_RELEASE_TAG run: ./internal-scripts/ci-cd/check-version-numbers-need-changing/determine-latest-release-tag.sh - - name: Free up disk space - run: sudo rm -rf /usr/share/dotnet "$AGENT_TOOLSDIRECTORY" - - name: Upload DEBs to repo run: ./internal-scripts/ci-cd/publish/publish-debs.rb pkgs/*/*.deb env: diff --git a/.github/workflows/ci-cd-publish-test-test.yml b/.github/workflows/ci-cd-publish-test-test.yml index 03037600..6aef23a7 100644 --- a/.github/workflows/ci-cd-publish-test-test.yml +++ b/.github/workflows/ci-cd-publish-test-test.yml @@ -78,17 +78,23 @@ jobs: publish: name: Publish packages - # Ubuntu 22.04 runner has more free disk space than 20.04 - runs-on: ubuntu-22.04 + # Ubuntu 24.04 runner has more free disk space than 22.04 + runs-on: ubuntu-24.04 timeout-minutes: 30 permissions: packages: read needs: - determine_necessary_jobs steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Clean disk space + run: ./internal-scripts/ci-cd/publish/clean-disk-space.sh + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' - name: Login to Google Cloud uses: ./.github/actions/gcloud-login with: @@ -129,9 +135,6 @@ jobs: # Sets environment variable $LATEST_RELEASE_TAG run: ./internal-scripts/ci-cd/check-version-numbers-need-changing/determine-latest-release-tag.sh - - name: Free up disk space - run: sudo rm -rf /usr/share/dotnet "$AGENT_TOOLSDIRECTORY" - - name: Upload DEBs to repo run: ./internal-scripts/ci-cd/publish/publish-debs.rb pkgs/*/*.deb env: diff --git a/.github/workflows/ci-cd-publish-test-test.yml.erb b/.github/workflows/ci-cd-publish-test-test.yml.erb index c6d60e4b..100d3c49 100644 --- a/.github/workflows/ci-cd-publish-test-test.yml.erb +++ b/.github/workflows/ci-cd-publish-test-test.yml.erb @@ -68,17 +68,23 @@ jobs: publish: name: Publish packages - # Ubuntu 22.04 runner has more free disk space than 20.04 - runs-on: ubuntu-22.04 + # Ubuntu 24.04 runner has more free disk space than 22.04 + runs-on: ubuntu-24.04 timeout-minutes: 30 permissions: packages: read needs: - determine_necessary_jobs steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Clean disk space + run: ./internal-scripts/ci-cd/publish/clean-disk-space.sh + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' - name: Login to Google Cloud uses: ./.github/actions/gcloud-login with: @@ -119,9 +125,6 @@ jobs: # Sets environment variable $LATEST_RELEASE_TAG run: ./internal-scripts/ci-cd/check-version-numbers-need-changing/determine-latest-release-tag.sh - - name: Free up disk space - run: sudo rm -rf /usr/share/dotnet "$AGENT_TOOLSDIRECTORY" - - name: Upload DEBs to repo run: ./internal-scripts/ci-cd/publish/publish-debs.rb pkgs/*/*.deb env: diff --git a/internal-scripts/ci-cd/publish/clean-disk-space.sh b/internal-scripts/ci-cd/publish/clean-disk-space.sh new file mode 100755 index 00000000..badfd712 --- /dev/null +++ b/internal-scripts/ci-cd/publish/clean-disk-space.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +echo "### Free disk space before cleaning:" +df -h + +# Based on https://stackoverflow.com/questions/75536771/github-runner-out-of-disk-space-after-building-docker-image +echo +echo "### Cleaning...." +sudo rm -rf "$AGENT_TOOLSDIRECTORY" /usr/share/dotnet /usr/local/lib/android /opt/ghc \ + /usr/local/share/powershell /usr/share/swift /usr/local/.ghcup /usr/lib/jvm +sudo apt purge -y aria2 shellcheck zsync google-chrome-stable \ + ant ant-optional kubectl mercurial apt-transport-https yarn libssl-dev \ + libfreetype6-dev libfontconfig1 snmp pollinate libpq-dev sphinxsearch +sudo apt purge -y '^mysql' +sudo apt purge -y '^php' +sudo apt purge -y '^dotnet' +sudo apt autoremove -y +sudo apt autoclean -y + +echo +echo "### Free disk space after cleaning:" +df -h