github: Only store (and delete) caches for branches not PRs

This commit is contained in:
Tobias Brunner
2026-05-08 14:42:30 +02:00
parent 93cf3de1fc
commit daa0b109da
6 changed files with 30 additions and 19 deletions
+3 -2
View File
@@ -71,10 +71,11 @@ jobs:
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} 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: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ${{ steps.cache-restore.outputs.cache-primary-key }} key: ${{ steps.cache-restore.outputs.cache-primary-key }}
+12 -7
View File
@@ -71,9 +71,10 @@ jobs:
# one specific config in case there is a race # one specific config in case there is a race
STORE_CACHE: >- STORE_CACHE: >-
${{ ${{
!contains(fromJSON('["all", "default", "printf-builtin"]'), github.event_name == 'push' &&
(!contains(fromJSON('["all", "default", "printf-builtin"]'),
matrix.test) || matrix.test) ||
(matrix.leak-detective == 'no' && matrix.monolithic == 'no') (matrix.leak-detective == 'no' && matrix.monolithic == 'no'))
}} }}
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
@@ -145,7 +146,9 @@ jobs:
CC: ${{ matrix.compiler || 'gcc' }} CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }} TEST: ${{ matrix.test }}
ACTIVE_TRANSFORMS_REF: .github/active-transforms/${{ 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: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- uses: actions/cache/restore@v5 - uses: actions/cache/restore@v5
@@ -227,10 +230,11 @@ jobs:
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} 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: with:
path: | path: |
~/.cache/ccache ~/.cache/ccache
@@ -271,10 +275,11 @@ jobs:
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete --repo ${{ github.repository }} -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} 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: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ${{ steps.cache-restore.outputs.cache-primary-key }} key: ${{ steps.cache-restore.outputs.cache-primary-key }}
+3 -2
View File
@@ -55,10 +55,11 @@ jobs:
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} 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: with:
path: ~/Library/Caches/ccache path: ~/Library/Caches/ccache
key: ${{ steps.cache-restore.outputs.cache-primary-key }} key: ${{ steps.cache-restore.outputs.cache-primary-key }}
+3 -2
View File
@@ -62,10 +62,11 @@ jobs:
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} 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: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ${{ steps.cache-restore.outputs.cache-primary-key }} key: ${{ steps.cache-restore.outputs.cache-primary-key }}
+3 -2
View File
@@ -79,10 +79,11 @@ jobs:
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} 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: with:
path: ${{ env.CCACHE_DIR }} path: ${{ env.CCACHE_DIR }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }} key: ${{ steps.cache-restore.outputs.cache-primary-key }}
+6 -4
View File
@@ -56,10 +56,11 @@ jobs:
# delete old cache entry as we currently can't update it any other way # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} 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: with:
path: ~/.cache/ccache path: ~/.cache/ccache
key: ${{ steps.cache-restore.outputs.cache-primary-key }} 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 # delete old cache entry as we currently can't update it any other way
- env: - env:
GH_TOKEN: ${{ github.token }} 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 continue-on-error: true
run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }} run: gh cache delete -r ${{ github.ref }} ${{ steps.cache-restore.outputs.cache-primary-key }}
shell: bash shell: bash
- uses: actions/cache/save@v5 - if: github.event_name == 'push'
uses: actions/cache/save@v5
with: with:
path: ~\AppData\Local\ccache path: ~\AppData\Local\ccache
key: ${{ steps.cache-restore.outputs.cache-primary-key }} key: ${{ steps.cache-restore.outputs.cache-primary-key }}