mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-22 00:33:57 +08:00
Add fail-on-cache-miss
option (#1036)
* Add fail-on-cache-miss option * Small improvements * Changes after rebase * Update description * Only fail if no cache entry is found * Code review * Update readme * Add additional test case * Bump version + changelog * Update package-lock.json * Update Readme
This commit is contained in:
parent
8e3048d0f7
commit
627f0f41f6
15 changed files with 174 additions and 15 deletions
|
@ -7,6 +7,7 @@ The restore action, as the name suggest, restores a cache. It acts similar to th
|
|||
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||
* `key` - String used while saving cache for restoring the cache
|
||||
* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.
|
||||
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: false
|
||||
|
||||
## Outputs
|
||||
|
||||
|
@ -95,7 +96,7 @@ steps:
|
|||
|
||||
### Exit workflow on cache miss
|
||||
|
||||
You can use the output of this action to exit the workflow on cache miss. This way you can restrict your workflow to only initiate the build when `cache-hit` occurs, in other words, cache with exact key is found.
|
||||
You can use `fail-on-cache-miss: true` to exit the workflow on a cache miss. This way you can restrict your workflow to only initiate the build when a cache is matched. Also, if you want to fail if cache did not match primary key, additionally leave `restore-keys` empty!
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
|
@ -106,10 +107,7 @@ steps:
|
|||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Check cache hit
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: exit 1
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: Build
|
||||
run: /build.sh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue