mirror of
https://github.com/actions/cache.git
synced 2025-04-21 11:36:45 +00:00
Add option to re-evaluate cache key during post action
This commit is contained in:
parent
5a3ec84eff
commit
f0a29e5cc9
4 changed files with 10 additions and 4 deletions
|
@ -76,6 +76,7 @@ If you are using a `self-hosted` Windows runner, `GNU tar` and `zstd` are requir
|
||||||
* `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false`
|
* `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false`
|
||||||
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false`
|
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false`
|
||||||
* `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false`
|
* `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false`
|
||||||
|
* `reeval-key` - A boolean which causes the key to be re-evaluated during the Post-Action step
|
||||||
|
|
||||||
#### Environment Variables
|
#### Environment Variables
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ inputs:
|
||||||
save-always does not work as intended and will be removed in a future release.
|
save-always does not work as intended and will be removed in a future release.
|
||||||
A separate `actions/cache/restore` step should be used instead.
|
A separate `actions/cache/restore` step should be used instead.
|
||||||
See https://github.com/actions/cache/tree/main/save#always-save-cache for more details.
|
See https://github.com/actions/cache/tree/main/save#always-save-cache for more details.
|
||||||
|
reeval-key:
|
||||||
|
description: 'Re-evaluate the cache key during the post-action'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
outputs:
|
outputs:
|
||||||
cache-hit:
|
cache-hit:
|
||||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||||
|
|
|
@ -5,7 +5,8 @@ export enum Inputs {
|
||||||
UploadChunkSize = "upload-chunk-size", // Input for cache, save action
|
UploadChunkSize = "upload-chunk-size", // Input for cache, save action
|
||||||
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
|
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
|
||||||
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action
|
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action
|
||||||
LookupOnly = "lookup-only" // Input for cache, restore action
|
LookupOnly = "lookup-only", // Input for cache, restore action
|
||||||
|
ReEvalKey = "reeval-key"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Outputs {
|
export enum Outputs {
|
||||||
|
|
|
@ -34,9 +34,9 @@ export async function saveImpl(
|
||||||
|
|
||||||
// If restore has stored a primary key in state, reuse that
|
// If restore has stored a primary key in state, reuse that
|
||||||
// Else re-evaluate from inputs
|
// Else re-evaluate from inputs
|
||||||
const primaryKey =
|
const primaryKey = core.getBooleanInput(Inputs.ReEvalKey)
|
||||||
stateProvider.getState(State.CachePrimaryKey) ||
|
? core.getInput(Inputs.Key)
|
||||||
core.getInput(Inputs.Key);
|
: (stateProvider.getState(State.CachePrimaryKey) || core.getInput(Inputs.Key));
|
||||||
|
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
utils.logWarning(`Key is not specified.`);
|
utils.logWarning(`Key is not specified.`);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue