mirror of
https://code.forgejo.org/actions/cache.git
synced 2026-05-11 06:52:29 +00:00
Add fail-on-error input to fail workflow on cache save errors
This commit is contained in:
parent
27d5ce7f10
commit
b3c661a9c5
8 changed files with 119 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ The save action saves a cache. It works similarly to the `cache` action except t
|
|||
* `key` - An explicit key for a cache entry. See [creating a cache key](../README.md#creating-a-cache-key).
|
||||
* `path` - A list of files, directories, and wildcard patterns to cache. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||
* `upload-chunk-size` - The chunk size used to split up large files during upload, in bytes
|
||||
* `fail-on-error` - Fail the workflow if the cache save encounters an error, rather than logging a warning and succeeding. Default: `false`
|
||||
|
||||
### Outputs
|
||||
|
||||
|
|
@ -68,6 +69,24 @@ with:
|
|||
key: npm-cache-${{hashfiles(package-lock.json)}}
|
||||
```
|
||||
|
||||
### Fail workflow on save error
|
||||
|
||||
By default, errors during cache save (such as exceeding the cache size limit or a network failure) log a warning and allow the workflow to continue. Use `fail-on-error: true` to treat any save error as a workflow failure instead.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install Dependencies
|
||||
run: /install.sh
|
||||
|
||||
- uses: actions/cache/save@v5
|
||||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
fail-on-error: true
|
||||
```
|
||||
|
||||
### Always save cache
|
||||
|
||||
There are instances where some flaky test cases would fail the entire workflow and users would get frustrated because the builds would run for hours and the cache couldn't be saved as the workflow failed in between.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ inputs:
|
|||
description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms'
|
||||
default: 'false'
|
||||
required: false
|
||||
fail-on-error:
|
||||
description: 'Fail the workflow if cache save fails'
|
||||
default: 'false'
|
||||
required: false
|
||||
runs:
|
||||
using: 'node24'
|
||||
main: '../dist/save-only/index.js'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue