Compare commits

...

3 Commits

Author SHA1 Message Date
itchyny 1f14885662
Merge 5cdbd5c7ec into 8469c94c6a 2024-10-09 08:16:52 +09:00
Jan T. Sott 8469c94c6a
Add Bun example (#1456)
* Add Bun example

* Fix Bun Windows example
2024-10-08 19:53:09 +00:00
itchyny 5cdbd5c7ec Avoid re-evaluation of the key input in restore implementation 2024-10-06 08:41:39 +09:00
5 changed files with 25 additions and 7 deletions

View File

@ -157,6 +157,7 @@ Every programming language and framework has its own way of caching.
See [Examples](examples.md) for a list of `actions/cache` implementations for use with:
* [Bun](./examples.md#bun)
* [C# - NuGet](./examples.md#c---nuget)
* [Clojure - Lein Deps](./examples.md#clojure---lein-deps)
* [D - DUB](./examples.md#d---dub)

View File

@ -59428,7 +59428,7 @@ function restoreImpl(stateProvider, earlyExit) {
}
// Store the matched cache key in states
stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString());
if (lookupOnly) {
core.info(`Cache found and can be restored from key: ${cacheKey}`);

View File

@ -59428,7 +59428,7 @@ function restoreImpl(stateProvider, earlyExit) {
}
// Store the matched cache key in states
stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString());
if (lookupOnly) {
core.info(`Cache found and can be restored from key: ${cacheKey}`);

View File

@ -1,5 +1,6 @@
# Examples
- [Bun](#bun)
- [C# - NuGet](#c---nuget)
- [Clojure - Lein Deps](#clojure---lein-deps)
- [D - DUB](#d---dub)
@ -41,6 +42,26 @@
- [Swift - Mint](#swift---mint)
- [* - Bazel](#---bazel)
## Bun
```yaml
- uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
```
### Windows
```yaml
- uses: actions/cache@v4
with:
path: |
~\.bun
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
```
## C# - NuGet
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):

View File

@ -71,11 +71,7 @@ export async function restoreImpl(
// Store the matched cache key in states
stateProvider.setState(State.CacheMatchedKey, cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(
core.getInput(Inputs.Key, { required: true }),
cacheKey
);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString());
if (lookupOnly) {
core.info(`Cache found and can be restored from key: ${cacheKey}`);