mirror of
https://code.forgejo.org/actions/cache.git
synced 2026-03-24 16:38:07 +03:00
Add OV input override-primary-key-env-variable for version v5
This commit is contained in:
parent
cdf6c1fa76
commit
11c99f79c6
4 changed files with 24 additions and 5 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
name: 'Cache'
|
name: 'Cache'
|
||||||
description: 'Cache artifacts like dependencies and build outputs to improve workflow execution time'
|
description: |
|
||||||
|
Cache artifacts like dependencies and build outputs to improve workflow execution time
|
||||||
|
|
||||||
|
OneVizion Improvements:
|
||||||
|
- Added ability to change primary key after restore cache. This is required when primary key initially can't be generated, only after cache restore
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
path:
|
path:
|
||||||
|
|
@ -34,6 +38,9 @@ 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.
|
||||||
|
override-primary-key-env-variable:
|
||||||
|
description: 'Environment variable to override primary key'
|
||||||
|
required: 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'
|
||||||
|
|
|
||||||
8
dist/save/index.js
vendored
8
dist/save/index.js
vendored
|
|
@ -46257,12 +46257,18 @@ function saveImpl(stateProvider) {
|
||||||
}
|
}
|
||||||
// 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 = stateProvider.getState(constants_1.State.CachePrimaryKey) ||
|
let primaryKey = stateProvider.getState(constants_1.State.CachePrimaryKey) ||
|
||||||
core.getInput(constants_1.Inputs.Key);
|
core.getInput(constants_1.Inputs.Key);
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
utils.logWarning(`Key is not specified.`);
|
utils.logWarning(`Key is not specified.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const overridePrimaryKeyEnvVariable = core.getInput('override-primary-key-env-variable');
|
||||||
|
if (overridePrimaryKeyEnvVariable !== undefined && process.env[overridePrimaryKeyEnvVariable] !== '') {
|
||||||
|
core.info(`Primary key has been overridden to ${process.env[overridePrimaryKeyEnvVariable]}, was ${primaryKey}.`);
|
||||||
|
primaryKey = process.env[overridePrimaryKeyEnvVariable] || '';
|
||||||
|
}
|
||||||
|
|
||||||
// If matched restore key is same as primary key, then do not save cache
|
// If matched restore key is same as primary key, then do not save cache
|
||||||
// NO-OP in case of SaveOnly action
|
// NO-OP in case of SaveOnly action
|
||||||
const restoredKey = stateProvider.getCacheState();
|
const restoredKey = stateProvider.getCacheState();
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "5.0.2",
|
"version": "5.0.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "5.0.2",
|
"version": "5.0.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^5.0.5",
|
"@actions/cache": "^5.0.5",
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ 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 =
|
let primaryKey =
|
||||||
stateProvider.getState(State.CachePrimaryKey) ||
|
stateProvider.getState(State.CachePrimaryKey) ||
|
||||||
core.getInput(Inputs.Key);
|
core.getInput(Inputs.Key);
|
||||||
|
|
||||||
|
|
@ -43,6 +43,12 @@ export async function saveImpl(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const overridePrimaryKeyEnvVariable = core.getInput('override-primary-key-env-variable');
|
||||||
|
if (overridePrimaryKeyEnvVariable !== undefined && process.env[overridePrimaryKeyEnvVariable] !== '') {
|
||||||
|
core.info(`Primary key has been overridden to ${process.env[overridePrimaryKeyEnvVariable]}, was ${primaryKey}.`);
|
||||||
|
primaryKey = process.env[overridePrimaryKeyEnvVariable] || '';
|
||||||
|
}
|
||||||
|
|
||||||
// If matched restore key is same as primary key, then do not save cache
|
// If matched restore key is same as primary key, then do not save cache
|
||||||
// NO-OP in case of SaveOnly action
|
// NO-OP in case of SaveOnly action
|
||||||
const restoredKey = stateProvider.getCacheState();
|
const restoredKey = stateProvider.getCacheState();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue