Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cachePath as an output for easier access #1436

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update typescript files to implement cachePath
  • Loading branch information
Ella Kramer authored and Ella Kramer committed Jul 19, 2024
commit b0a3f6e7a6068d41aabaae75f3a49a51c5a545ef
6 changes: 4 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -11,12 +11,14 @@ export enum Inputs {
export enum Outputs {
CacheHit = "cache-hit", // Output from cache, restore action
CachePrimaryKey = "cache-primary-key", // Output from restore action
CacheMatchedKey = "cache-matched-key" // Output from restore action
CacheMatchedKey = "cache-matched-key", // Output from restore action
CachePath = "cache-path" // Output from restore action
}

export enum State {
CachePrimaryKey = "CACHE_KEY",
CacheMatchedKey = "CACHE_RESULT"
CacheMatchedKey = "CACHE_RESULT",
CachePath = "CACHE_PATH"
}

export enum Events {
2 changes: 2 additions & 0 deletions src/restoreImpl.ts
Original file line number Diff line number Diff line change
@@ -32,6 +32,8 @@ export async function restoreImpl(
const primaryKey = core.getInput(Inputs.Key, { required: true });
stateProvider.setState(State.CachePrimaryKey, primaryKey);

stateProvider.setState(State.CachePath, core.getInput(Inputs.Path)); // Output path unchanged from input

const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
const cachePaths = utils.getInputAsArray(Inputs.Path, {
required: true
3 changes: 2 additions & 1 deletion src/stateProvider.ts
Original file line number Diff line number Diff line change
@@ -35,7 +35,8 @@ export class StateProvider extends StateProviderBase {
export class NullStateProvider extends StateProviderBase {
stateToOutputMap = new Map<string, string>([
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
[State.CachePrimaryKey, Outputs.CachePrimaryKey],
[State.CachePath, Outputs.CachePath]
]);

setState = (key: string, value: string) => {