1
0
Fork 0
mirror of synced 2026-06-05 15:05:14 +00:00

checking cache event in pre-step

This commit is contained in:
h0x0er 2022-09-26 22:25:28 +05:30
commit bac73aa464

View file

@ -8,7 +8,13 @@ import * as common from "./common";
import * as tc from "@actions/tool-cache"; import * as tc from "@actions/tool-cache";
import { verifyChecksum } from "./checksum"; import { verifyChecksum } from "./checksum";
import isDocker from "is-docker"; import isDocker from "is-docker";
import { cacheFile, cacheKey, CompressionMethod, getCacheEntry } from "./cache"; import {
cacheFile,
cacheKey,
CompressionMethod,
getCacheEntry,
isValidEvent,
} from "./cache";
(async () => { (async () => {
try { try {
@ -39,21 +45,21 @@ import { cacheFile, cacheKey, CompressionMethod, getCacheEntry } from "./cache";
disable_telemetry: core.getBooleanInput("disable-telemetry"), disable_telemetry: core.getBooleanInput("disable-telemetry"),
}; };
try { if (isValidEvent()) {
const cacheEntry = await getCacheEntry([cacheKey], [cacheFile], { try {
compressionMethod: CompressionMethod.ZstdWithoutLong, const cacheEntry = await getCacheEntry([cacheKey], [cacheFile], {
}); compressionMethod: CompressionMethod.ZstdWithoutLong,
const url = new URL(cacheEntry.archiveLocation); });
core.info(`Adding cacheHost: ${url.hostname}:443 to allowed-endpoints`); const url = new URL(cacheEntry.archiveLocation);
confg.allowed_endpoints += ` ${url.hostname}:443`; core.info(`Adding cacheHost: ${url.hostname}:443 to allowed-endpoints`);
} catch (exception) { confg.allowed_endpoints += ` ${url.hostname}:443`;
// some exception has occurred. } catch (exception) {
core.info("Unable to fetch cacheURL"); // some exception has occurred.
if (confg.egress_policy === "block") { core.info("Unable to fetch cacheURL");
core.warning( if (confg.egress_policy === "block") {
"Unable to fetch cacheURL switching egress-policy to audit mode" core.info("Switching egress-policy to audit mode");
); confg.egress_policy = "audit";
confg.egress_policy = "audit"; }
} }
} }