|
|
@ -1,4 +1,6 @@
|
|
|
|
import * as cache from "@actions/cache";
|
|
|
|
import * as cache from "@actions/cache";
|
|
|
|
|
|
|
|
import { getCacheEntry } from "@actions/cache/lib/internal/cacheHttpClient";
|
|
|
|
|
|
|
|
import { getCompressionMethod } from "@actions/cache/lib/internal/cacheUtils";
|
|
|
|
import * as core from "@actions/core";
|
|
|
|
import * as core from "@actions/core";
|
|
|
|
|
|
|
|
|
|
|
|
import { Events, Inputs, State } from "./constants";
|
|
|
|
import { Events, Inputs, State } from "./constants";
|
|
|
@ -23,30 +25,48 @@ async function run(): Promise<void> {
|
|
|
|
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
|
|
|
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
const onlyCheck = utils.getInputAsBool(Inputs.OnlyCheckKey);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const cacheKey = await cache.restoreCache(
|
|
|
|
if (onlyCheck) {
|
|
|
|
cachePaths,
|
|
|
|
const entry = await getCacheEntry([primaryKey], cachePaths, {
|
|
|
|
primaryKey,
|
|
|
|
compressionMethod: await getCompressionMethod()
|
|
|
|
restoreKeys
|
|
|
|
});
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!cacheKey) {
|
|
|
|
if (entry && entry.archiveLocation) {
|
|
|
|
core.info(
|
|
|
|
core.info(`Cache found for key: ${primaryKey}`);
|
|
|
|
`Cache not found for input keys: ${[
|
|
|
|
utils.setCacheHitOutput(true);
|
|
|
|
primaryKey,
|
|
|
|
} else {
|
|
|
|
...restoreKeys
|
|
|
|
core.info(`Cache not found for key: ${primaryKey}`);
|
|
|
|
].join(", ")}`
|
|
|
|
utils.setCacheHitOutput(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const cacheKey = await cache.restoreCache(
|
|
|
|
|
|
|
|
cachePaths,
|
|
|
|
|
|
|
|
primaryKey,
|
|
|
|
|
|
|
|
restoreKeys
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
if (!cacheKey) {
|
|
|
|
}
|
|
|
|
core.info(
|
|
|
|
|
|
|
|
`Cache not found for input keys: ${[
|
|
|
|
|
|
|
|
primaryKey,
|
|
|
|
|
|
|
|
...restoreKeys
|
|
|
|
|
|
|
|
].join(", ")}`
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Store the matched cache key
|
|
|
|
// Store the matched cache key
|
|
|
|
utils.setCacheState(cacheKey);
|
|
|
|
utils.setCacheState(cacheKey);
|
|
|
|
|
|
|
|
|
|
|
|
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
|
|
|
const isExactKeyMatch = utils.isExactKeyMatch(
|
|
|
|
utils.setCacheHitOutput(isExactKeyMatch);
|
|
|
|
primaryKey,
|
|
|
|
|
|
|
|
cacheKey
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
utils.setCacheHitOutput(isExactKeyMatch);
|
|
|
|
|
|
|
|
|
|
|
|
core.info(`Cache restored from key: ${cacheKey}`);
|
|
|
|
core.info(`Cache restored from key: ${cacheKey}`);
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
if (error.name === cache.ValidationError.name) {
|
|
|
|
if (error.name === cache.ValidationError.name) {
|
|
|
|
throw error;
|
|
|
|
throw error;
|
|
|
|