Compare commits

...

4 Commits

Author SHA1 Message Date
Antoine Toulme
0a6e397f3f
Merge 3b3fb41561 into 5656298164 2026-02-26 11:33:01 +00:00
Ryan Ghadimi
5656298164
Merge pull request #1722 from RyPeck/patch-1
Fix cache key in examples.md for bun.lock
2026-02-24 14:21:04 +00:00
Ryan Peck
4e380d19e1
Fix cache key in examples.md for bun.lock
Updated cache key to use 'bun.lock' instead of 'bun.lockb' for consistency.
2026-02-24 09:11:36 -05:00
github-actions[bot]
3b3fb41561 Offer a strategy to reduce cache churn 2025-08-07 23:20:34 -07:00
2 changed files with 25 additions and 2 deletions

View File

@ -287,3 +287,26 @@ steps:
- name: Publish package to public
run: ./publish.sh
```
### Saving cache only if the build runs on the default branch
Workflow runs can restore caches created in either the current branch or the default branch (usually `main`) [Reference](https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache).
By restricting caches to the default branch, we can reduce the risk that Github evicts a cache created on the default branch. If that happens, every PR will create its own cache, increasing the cache churn.
We can condition the execution of the `actions/cache/save` action on the current branch:
```yaml
steps:
- uses: actions/checkout@v3
.
. // restore if need be
.
- name: Build
run: /build.sh
- uses: actions/cache/save@v3
if: ${{ github.ref == 'refs/heads/main' }} // check we are on the default branch
with:
path: path/to/dependencies
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
```

View File

@ -49,7 +49,7 @@
with:
path: |
~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
```
### Windows
@ -59,7 +59,7 @@
with:
path: |
~\.bun
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
```
## C# - NuGet