Skip to content

Commit 7909c77

Browse files
committed
CI: Only save cache on main
Our caches are rather big (nearly all of the total quota). Unless the cache was built from the default branch, it can only be used from the same branch as the run that pushed it. This means that we end up pushing lots of cache that can never be reused, causing the actually useful ones (i.e. the caches from the default branch) to be evicted due to space. Fix this by using explicit cache save and restore, and then limiting the save to only apply on the main branch. Signed-off-by: Mark Yen <mark.yen@suse.com>
1 parent fdda74f commit 7909c77

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/build.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ jobs:
4040
buildkitd-flags: "--allow-insecure-entitlement security.insecure"
4141
platforms: linux/${{ matrix.arch }}
4242

43-
- name: Set up Docker layer cache
44-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
43+
- name: Restore Docker layer cache
44+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
4545
with:
4646
path: ${{ runner.temp }}/cache
4747
key: ${{ runner.arch }}-buildx-${{ matrix.type }}-${{ github.sha }}
@@ -62,3 +62,10 @@ jobs:
6262
with:
6363
name: distro-${{ matrix.type }}-${{ matrix.arch }}
6464
path: distro.${{ matrix.type }}
65+
66+
- name: Save Docker layer cache
67+
if: github.ref == 'refs/heads/main'
68+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
69+
with:
70+
path: ${{ runner.temp }}/cache
71+
key: ${{ runner.arch }}-buildx-${{ matrix.type }}-${{ github.sha }}

0 commit comments

Comments
 (0)