From daa0b109daf7870c153ee225896f9b57dacc336c Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 8 May 2026 14:42:30 +0200 Subject: [PATCH] github: Only store (and delete) caches for branches not PRs --- .github/workflows/android.yml | 5 +++-- .github/workflows/linux.yml | 19 ++++++++++++------- .github/workflows/macos.yml | 5 +++-- .github/workflows/sonarcloud.yml | 5 +++-- .github/workflows/tkm.yml | 5 +++-- .github/workflows/windows.yml | 10 ++++++---- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 79c91c3f7..4dff2256c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -71,10 +71,11 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: ~/.cache/ccache key: ${{ steps.cache-restore.outputs.cache-primary-key }} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 492ea9d21..6a112a72a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -71,9 +71,10 @@ jobs: # one specific config in case there is a race STORE_CACHE: >- ${{ - !contains(fromJSON('["all", "default", "printf-builtin"]'), + github.event_name == 'push' && + (!contains(fromJSON('["all", "default", "printf-builtin"]'), matrix.test) || - (matrix.leak-detective == 'no' && matrix.monolithic == 'no') + (matrix.leak-detective == 'no' && matrix.monolithic == 'no')) }} steps: - uses: actions/checkout@v6 @@ -145,7 +146,9 @@ jobs: CC: ${{ matrix.compiler || 'gcc' }} TEST: ${{ matrix.test }} ACTIVE_TRANSFORMS_REF: .github/active-transforms/${{ matrix.test }} - STORE_CACHE: ${{ !matrix.leak-detective || matrix.leak-detective == 'no' }} + STORE_CACHE: >- + ${{ github.event_name == 'push' && + (!matrix.leak-detective || matrix.leak-detective == 'no') }} steps: - uses: actions/checkout@v6 - uses: actions/cache/restore@v5 @@ -227,10 +230,11 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: | ~/.cache/ccache @@ -271,10 +275,11 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete --repo ${{ github.repository }} -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: ~/.cache/ccache key: ${{ steps.cache-restore.outputs.cache-primary-key }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 4644f1983..c74d73a8d 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -55,10 +55,11 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: ~/Library/Caches/ccache key: ${{ steps.cache-restore.outputs.cache-primary-key }} diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 17340d468..9b8cb2688 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -62,10 +62,11 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: ~/.cache/ccache key: ${{ steps.cache-restore.outputs.cache-primary-key }} diff --git a/.github/workflows/tkm.yml b/.github/workflows/tkm.yml index d57cb4437..9d10376a6 100644 --- a/.github/workflows/tkm.yml +++ b/.github/workflows/tkm.yml @@ -79,10 +79,11 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: ${{ env.CCACHE_DIR }} key: ${{ steps.cache-restore.outputs.cache-primary-key }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6cf331a02..e8cb20861 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -56,10 +56,11 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: ~/.cache/ccache key: ${{ steps.cache-restore.outputs.cache-primary-key }} @@ -116,11 +117,12 @@ jobs: # delete old cache entry as we currently can't update it any other way - env: GH_TOKEN: ${{ github.token }} - if: steps.cache-restore.outputs.cache-hit + if: github.event_name == 'push' && steps.cache-restore.outputs.cache-hit continue-on-error: true run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} shell: bash - - uses: actions/cache/save@v5 + - if: github.event_name == 'push' + uses: actions/cache/save@v5 with: path: ~\AppData\Local\ccache key: ${{ steps.cache-restore.outputs.cache-primary-key }}