CI: build: limit cache save/delete only on push events
authorChristian Marangi <ansuelsmth@gmail.com>
Sun, 28 May 2023 07:11:29 +0000 (09:11 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Wed, 31 May 2023 11:22:05 +0000 (13:22 +0200)
Limit ccache cache save/delete only on push events. Saving ccache
cache for pull request will result in bloat and refreshing ccache is not
possible due to security measure on enforcing read permission on
pull_request events.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
.github/workflows/build.yml

index 0c0c05f402b7048a290e320bab8d21c86dae15c0..95d19f4c4e0b6e80730c498a52ca424c170b1fa2 100644 (file)
@@ -498,7 +498,7 @@ jobs:
           path: "openwrt/logs"
 
       - name: Delete already present ccache cache
-        if: steps.restore-ccache-cache.outputs.cache-hit == 'true' && inputs.use_ccache_cache == true
+        if: steps.restore-ccache-cache.outputs.cache-hit == 'true' && inputs.use_ccache_cache == true  && github.event_name == 'push'
         uses: octokit/request-action@v2.x
         with:
           route: DELETE /repos/{repository}/actions/caches?key={key}
@@ -508,7 +508,7 @@ jobs:
           INPUT_KEY: ${{ steps.restore-ccache-cache.outputs.cache-primary-key }}
 
       - name: Save ccache cache
-        if: inputs.use_ccache_cache == true
+        if: inputs.use_ccache_cache == true && github.event_name == 'push'
         uses: actions/cache/save@v3
         with:
           path: openwrt/.ccache