Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 0a36ca9

Browse files
committedJun 4, 2022
Use 'cache-read-only' for all but default_branch
Cache entries _written_ from jobs run on a non-default branch will be private to other jobs for that branch. When development flow involves working on a feature branch and then merging into 'main', these branch-private cache entries can result in eviction of other (shared) cache entries generated for the default branch. With this change, we make the recommended setup the default, by running with `cache-read-only: true` for any jobs run on a non-default branch. These jobs will be able to read cache entries written from the main branch, but will not write any cache entries. Fixes #143
1 parent fe92974 commit 0a36ca9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎action.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ inputs:
1414
default: false
1515

1616
cache-read-only:
17-
description: When 'true', existing entries will be read from the cache but no entries will be written.
17+
description: |
18+
When 'true', existing entries will be read from the cache but no entries will be written.
19+
By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches.
1820
required: false
19-
default: false
21+
default: ${{ github.ref_name != github.event.repository.default_branch }}
2022
# e.g. Use the following setting to only write cache entries from your 'main' branch
21-
# cache-read-only: ${{ github.ref != 'refs/heads/main' }}
23+
# cache-read-only: ${{ github.ref_name != 'main' }}
2224

2325
gradle-home-cache-includes:
2426
description: Paths within Gradle User Home to cache.

0 commit comments

Comments
 (0)