mirror of
https://github.com/actions/cache.git
synced 2024-11-22 09:51:25 +01:00
Add paths as an output for easier access
This commit is contained in:
parent
0c45773b62
commit
b6cff214f7
3 changed files with 38 additions and 28 deletions
9
dist/restore-only/index.js
vendored
9
dist/restore-only/index.js
vendored
|
@ -59331,11 +59331,13 @@ var Outputs;
|
||||||
Outputs["CacheHit"] = "cache-hit";
|
Outputs["CacheHit"] = "cache-hit";
|
||||||
Outputs["CachePrimaryKey"] = "cache-primary-key";
|
Outputs["CachePrimaryKey"] = "cache-primary-key";
|
||||||
Outputs["CacheMatchedKey"] = "cache-matched-key"; // Output from restore action
|
Outputs["CacheMatchedKey"] = "cache-matched-key"; // Output from restore action
|
||||||
|
Outputs["CachePath"] = "cache-path";
|
||||||
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
||||||
var State;
|
var State;
|
||||||
(function (State) {
|
(function (State) {
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
|
State["CachePath"] = "CACHE_PATH";
|
||||||
})(State = exports.State || (exports.State = {}));
|
})(State = exports.State || (exports.State = {}));
|
||||||
var Events;
|
var Events;
|
||||||
(function (Events) {
|
(function (Events) {
|
||||||
|
@ -59407,6 +59409,10 @@ function restoreImpl(stateProvider, earlyExit) {
|
||||||
const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
|
const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
|
||||||
stateProvider.setState(constants_1.State.CachePrimaryKey, primaryKey);
|
stateProvider.setState(constants_1.State.CachePrimaryKey, primaryKey);
|
||||||
const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
|
const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
|
||||||
|
|
||||||
|
// Output the inputted path unchanged
|
||||||
|
stateProvider.setState(constants_1.State.CachePath, getInput(constants_1.Inputs.Path));
|
||||||
|
|
||||||
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
|
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
|
@ -59535,7 +59541,8 @@ class NullStateProvider extends StateProviderBase {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
this.stateToOutputMap = new Map([
|
this.stateToOutputMap = new Map([
|
||||||
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
|
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
|
||||||
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
|
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey],
|
||||||
|
[constants_1.State.CachePath, constants_1.Outputs.CachePath]
|
||||||
]);
|
]);
|
||||||
this.setState = (key, value) => {
|
this.setState = (key, value) => {
|
||||||
core.setOutput(this.stateToOutputMap.get(key), value);
|
core.setOutput(this.stateToOutputMap.get(key), value);
|
||||||
|
|
|
@ -17,6 +17,7 @@ The restore action restores a cache. It works similarly to the `cache` action ex
|
||||||
* `cache-hit` - A boolean value to indicate an exact match was found for the key.
|
* `cache-hit` - A boolean value to indicate an exact match was found for the key.
|
||||||
* `cache-primary-key` - Cache primary key passed in the input to use in subsequent steps of the workflow.
|
* `cache-primary-key` - Cache primary key passed in the input to use in subsequent steps of the workflow.
|
||||||
* `cache-matched-key` - Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys.
|
* `cache-matched-key` - Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys.
|
||||||
|
* `cache-path` - The list of files, directories, and wildcard patterns passed in the input.
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
`cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.
|
`cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.
|
||||||
|
|
|
@ -30,6 +30,8 @@ outputs:
|
||||||
description: 'A resolved cache key for which cache match was attempted'
|
description: 'A resolved cache key for which cache match was attempted'
|
||||||
cache-matched-key:
|
cache-matched-key:
|
||||||
description: 'Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys'
|
description: 'Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys'
|
||||||
|
cache-path:
|
||||||
|
description: 'The list of files, directories, and wildcard patterns passed in the input'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: '../dist/restore-only/index.js'
|
main: '../dist/restore-only/index.js'
|
||||||
|
|
Loading…
Reference in a new issue