Fixed inputs

This commit is contained in:
Sankalp Kotewar 2022-12-09 13:56:33 +00:00 committed by GitHub
parent 61aa90bfc3
commit d91f5bd2fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 95 additions and 44 deletions

View file

@ -2,7 +2,7 @@ import * as cache from "@actions/cache";
import * as core from "@actions/core";
import { Events, Inputs, State } from "./constants";
import { IStateProvider } from "./stateProvider";
import { IStateProvider, StateProvider } from "./stateProvider";
import * as utils from "./utils/actionUtils";
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
@ -32,14 +32,20 @@ async function saveImpl(stateProvider: IStateProvider): Promise<void> {
core.getInput(Inputs.Key);
if (!primaryKey) {
utils.logWarning(`Error retrieving key from state.`);
if (stateProvider instanceof StateProvider) {
utils.logWarning(`Error retrieving key from state.`);
} else {
utils.logWarning(`Error retrieving key from input.`);
}
return;
}
// If matched restore key is same as primary key, then do not save cache
// NO-OP in case of SaveOnly action
const state = stateProvider.getCacheState();
if (utils.isExactKeyMatch(primaryKey, state)) {
const restoredKey =
stateProvider.getCacheState() || core.getInput(Inputs.RestoredKey);
if (utils.isExactKeyMatch(primaryKey, restoredKey)) {
core.info(
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
);