From 717ccd5fe0b2112136403efa9f41c6b6342b644f Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Mon, 26 Jan 2026 19:04:59 +0100 Subject: [PATCH 1/2] chore: worflow for clean up self hosted macmini --- .github/workflows/self-hosted-cleanup.yml | 113 ++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/self-hosted-cleanup.yml diff --git a/.github/workflows/self-hosted-cleanup.yml b/.github/workflows/self-hosted-cleanup.yml new file mode 100644 index 00000000..12c45f80 --- /dev/null +++ b/.github/workflows/self-hosted-cleanup.yml @@ -0,0 +1,113 @@ +name: self-hosted-cleanup + +on: + workflow_dispatch: + schedule: + # Run every Sunday at 3am UTC + - cron: "0 3 * * 0" + +jobs: + cleanup: + runs-on: [self-hosted, macOS] + + steps: + - name: Disk space before cleanup + run: | + echo "=== Disk Space Before Cleanup ===" + df -h / + echo "" + echo "=== Large directories ===" + du -sh ~/Library/Developer/Xcode/DerivedData 2>/dev/null || echo "No DerivedData" + du -sh ~/Library/Caches/org.swift.swiftpm 2>/dev/null || echo "No SPM cache" + du -sh ~/Library/Developer/CoreSimulator 2>/dev/null || echo "No Simulator data" + du -sh ~/.npm 2>/dev/null || echo "No npm cache" + + - name: Clean Xcode DerivedData + run: | + echo "Cleaning Xcode DerivedData..." + rm -rf ~/Library/Developer/Xcode/DerivedData/* + rm -rf ~/Library/Developer/Xcode/Archives/* + echo "✅ Xcode DerivedData cleaned" + + - name: Clean Swift Package Manager caches + run: | + echo "Cleaning Swift Package Manager caches..." + rm -rf ~/Library/Caches/org.swift.swiftpm + rm -rf ~/Library/org.swift.swiftpm + echo "✅ SPM caches cleaned" + + - name: Clean iOS Simulator caches + run: | + echo "Shutting down all simulators..." + xcrun simctl shutdown all || true + + echo "Deleting unavailable simulators..." + xcrun simctl delete unavailable || true + + echo "Cleaning simulator caches..." + rm -rf ~/Library/Developer/CoreSimulator/Caches/* + + echo "✅ Simulator caches cleaned" + + - name: Clean Docker resources + run: | + echo "Cleaning Docker resources..." + + # Stop all running containers + docker ps -q | xargs -r docker stop || true + + # Remove all containers + docker container prune -f || true + + # Remove unused images + docker image prune -af || true + + # Remove unused volumes + docker volume prune -f || true + + # Remove unused networks + docker network prune -f || true + + # Full system prune (includes build cache) + docker system prune -af --volumes || true + + echo "✅ Docker resources cleaned" + + - name: Clean npm cache + run: | + echo "Cleaning npm cache..." + npm cache clean --force || true + rm -rf ~/.npm/_cacache + echo "✅ npm cache cleaned" + + - name: Clean Homebrew cache + run: | + echo "Cleaning Homebrew cache..." + brew cleanup -s || true + rm -rf ~/Library/Caches/Homebrew/* + echo "✅ Homebrew cache cleaned" + + - name: Clean GitHub Actions cache + run: | + echo "Cleaning old GitHub Actions artifacts..." + rm -rf ~/actions-runner/_work/_temp/* || true + rm -rf ~/actions-runner/_work/_actions/* || true + echo "✅ Actions temp files cleaned" + + - name: Clean system caches + run: | + echo "Cleaning system caches..." + rm -rf ~/Library/Caches/com.apple.dt.Xcode/* || true + rm -rf /tmp/com.apple.launchd.* || true + echo "✅ System caches cleaned" + + - name: Disk space after cleanup + run: | + echo "=== Disk Space After Cleanup ===" + df -h / + echo "" + echo "=== Remaining large directories ===" + du -sh ~/Library/Developer/Xcode/DerivedData 2>/dev/null || echo "No DerivedData" + du -sh ~/Library/Caches/org.swift.swiftpm 2>/dev/null || echo "No SPM cache" + du -sh ~/Library/Developer/CoreSimulator 2>/dev/null || echo "No Simulator data" + du -sh ~/.npm 2>/dev/null || echo "No npm cache" From b5943d507092300106058009382f0d9957046921 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 28 Jan 2026 10:57:21 +0100 Subject: [PATCH 2/2] chore: remove schedule and docker cleanup --- .github/workflows/self-hosted-cleanup.yml | 32 +++-------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/.github/workflows/self-hosted-cleanup.yml b/.github/workflows/self-hosted-cleanup.yml index 12c45f80..21e56381 100644 --- a/.github/workflows/self-hosted-cleanup.yml +++ b/.github/workflows/self-hosted-cleanup.yml @@ -2,9 +2,10 @@ name: self-hosted-cleanup on: workflow_dispatch: - schedule: - # Run every Sunday at 3am UTC - - cron: "0 3 * * 0" + +concurrency: + group: self-hosted-runner + cancel-in-progress: false jobs: cleanup: @@ -49,30 +50,6 @@ jobs: echo "✅ Simulator caches cleaned" - - name: Clean Docker resources - run: | - echo "Cleaning Docker resources..." - - # Stop all running containers - docker ps -q | xargs -r docker stop || true - - # Remove all containers - docker container prune -f || true - - # Remove unused images - docker image prune -af || true - - # Remove unused volumes - docker volume prune -f || true - - # Remove unused networks - docker network prune -f || true - - # Full system prune (includes build cache) - docker system prune -af --volumes || true - - echo "✅ Docker resources cleaned" - - name: Clean npm cache run: | echo "Cleaning npm cache..." @@ -98,7 +75,6 @@ jobs: run: | echo "Cleaning system caches..." rm -rf ~/Library/Caches/com.apple.dt.Xcode/* || true - rm -rf /tmp/com.apple.launchd.* || true echo "✅ System caches cleaned" - name: Disk space after cleanup