@ -109,6 +109,14 @@ The cache is scoped to the key, [version](#cache-version), and branch. The defau
See [Matching a cache key](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) for more info.
### Read-only access
Some workflow runs only have read-only access to the cache. A common case is a workflow triggered by a pull request from a fork: such runs can **restore** existing caches but may not be permitted to **save** new ones.
When the cache token is read-only, the save step does not fail the job. Instead, `@actions/cache` reports the denial once as a warning (for example, `Failed to save: ... cache write denied: ...`) and the step completes successfully without writing a cache entry. Restores in the same run continue to work as usual.
> **Note** This applies to the action's normal save path as well as the standalone [Save action](./save/README.md). If you intentionally want a restore-only setup, see [Make cache read only / Reuse cache from centralized job](./caching-strategies.md#make-cache-read-only--reuse-cache-from-centralized-job).
### Example cache workflow
#### Restoring and saving cache using a single action
- Bump `@actions/cache` to v5.1.0 to pick up [actions/toolkit#2435 Handle cache write error due to read-only token](https://github.com/actions/toolkit/pull/2435)
- Switch redundant "Cache save failed" warning to debug log in save-only
### 5.0.4
- Bump `minimatch` to v3.1.5 (fixes ReDoS via globstar patterns)
@ -387,7 +407,11 @@ function saveCacheV1(paths_1, key_1, options_1) {
thrownewError((_d=(_c=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_c===void0?void0:_c.message)!==null&&_d!==void0?_d:`Cache size of ~${Math.round(archiveFileSize/(1024*1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
}
else{
thrownewReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_e===void0?void0:_e.message}`);
@ -387,7 +407,11 @@ function saveCacheV1(paths_1, key_1, options_1) {
thrownewError((_d=(_c=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_c===void0?void0:_c.message)!==null&&_d!==void0?_d:`Cache size of ~${Math.round(archiveFileSize/(1024*1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
}
else{
thrownewReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_e===void0?void0:_e.message}`);
@ -387,7 +407,11 @@ function saveCacheV1(paths_1, key_1, options_1) {
thrownewError((_d=(_c=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_c===void0?void0:_c.message)!==null&&_d!==void0?_d:`Cache size of ~${Math.round(archiveFileSize/(1024*1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
}
else{
thrownewReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_e===void0?void0:_e.message}`);
@ -387,7 +407,11 @@ function saveCacheV1(paths_1, key_1, options_1) {
thrownewError((_d=(_c=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_c===void0?void0:_c.message)!==null&&_d!==void0?_d:`Cache size of ~${Math.round(archiveFileSize/(1024*1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
}
else{
thrownewReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e=reserveCacheResponse===null||reserveCacheResponse===void0?void0:reserveCacheResponse.error)===null||_e===void0?void0:_e.message}`);