Commit daa0b109da for strongswan.org

commit daa0b109daf7870c153ee225896f9b57dacc336c
Author: Tobias Brunner <tobias@strongswan.org>
Date:   Fri May 8 14:42:30 2026 +0200

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

diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
index 79c91c3f7c..4dff2256cc 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 492ea9d218..6a112a72ab 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 4644f19833..c74d73a8df 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 17340d4688..9b8cb26888 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 d57cb44376..9d10376a61 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 6cf331a02c..e8cb208615 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 }}