From 3f7d4abd443d9282bfd40ffeac9ab80508f656e3 Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Sun, 15 Sep 2024 07:49:38 +0100 Subject: [PATCH] Free some space on Mac CI runners --- .github/actions/disk-cleanup/action.yml | 33 +++++++++++++++++++++++++ .github/workflows/build.yml | 12 +++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/actions/disk-cleanup/action.yml diff --git a/.github/actions/disk-cleanup/action.yml b/.github/actions/disk-cleanup/action.yml new file mode 100644 index 000000000..3111aa326 --- /dev/null +++ b/.github/actions/disk-cleanup/action.yml @@ -0,0 +1,33 @@ +name: Disk cleanup +description: "Cleanup disk space" +runs: + using: composite + steps: + - name: Free up disk space + shell: bash + run: | + echo "Disk space before cleanup..." + df -h / + echo "Removing unnecessary files to free up disk space..." + # https://github.com/actions/runner-images/issues/2840 + sudo rm -rf \ + /opt/hostedtoolcache \ + /opt/google/chrome \ + /opt/microsoft/msedge \ + /opt/microsoft/powershell \ + /opt/pipx \ + /usr/lib/mono \ + /usr/local/julia* \ + /usr/local/lib/node_modules \ + /usr/local/share/chromium \ + /usr/local/share/powershell \ + /usr/share/dotnet \ + /usr/share/swift + echo "Searching for Xcode versions:" + find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 + echo "Removing old Xcode versions..." + find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 | grep -v `cat .xcode-version` | xargs rm -rf + echo "Available Xcode versions after removal:" + find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 + echo "Disk space after cleanup..." + df -h / diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4930e9d61..968309bb9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,6 +145,9 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cleanup Disk space in runner + uses: .github/actions/disk-cleanup + - name: set up JDK uses: actions/setup-java@v4 with: @@ -204,6 +207,9 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cleanup Disk space in runner + uses: .github/actions/disk-cleanup + - name: set up JDK uses: actions/setup-java@v4 with: @@ -260,6 +266,9 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cleanup Disk space in runner + uses: .github/actions/disk-cleanup + - name: set up JDK uses: actions/setup-java@v4 with: @@ -302,6 +311,9 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Cleanup Disk space in runner + uses: .github/actions/disk-cleanup + - uses: ruby/setup-ruby@v1 with: bundler-cache: true