From 8145b0792f50366d1a2a0bfde3853ea3c56f0577 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Sun, 11 Oct 2026 23:55:23 +0800 Subject: [PATCH] Free macOS Disk Space Only When the Build Might Not Fit (#16364) --- .github/workflows/build_orca.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 5797681d99..9ebc319bf9 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -179,6 +179,13 @@ jobs: if: runner.os == 'macOS' && !inputs.macos-combine-only && !vars.SELF_HOSTED run: | df -hI / + # Deleting the unused Xcodes takes minutes, so only do it when the + # build might not fit. A cold build uses under 4 GiB after this step. + avail_gib=$(df -g / | awk 'NR == 2 { print $4 }') + if [ "$avail_gib" -ge 15 ]; then + echo "$avail_gib GiB free, enough for the build" + exit 0 + fi # Keep only the selected Xcode xcode=$(basename "$(cd "$(xcode-select -p)/../.." && pwd -P)") sudo find /Applications -maxdepth 1 -type d -name "Xcode_*.app" ! -name "$xcode" -exec rm -rf {} +