Skip to content

Commit

Permalink
checking cache event in pre-step
Browse files Browse the repository at this point in the history
  • Loading branch information
h0x0er committed Sep 26, 2022
1 parent 1c6bba3 commit bac73aa
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import * as common from "./common";
import * as tc from "@actions/tool-cache";
import { verifyChecksum } from "./checksum";
import isDocker from "is-docker";
import { cacheFile, cacheKey, CompressionMethod, getCacheEntry } from "./cache";
import {
cacheFile,
cacheKey,
CompressionMethod,
getCacheEntry,
isValidEvent,
} from "./cache";

(async () => {
try {
Expand Down Expand Up @@ -39,21 +45,21 @@ import { cacheFile, cacheKey, CompressionMethod, getCacheEntry } from "./cache";
disable_telemetry: core.getBooleanInput("disable-telemetry"),
};

try {
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`);
confg.allowed_endpoints += ` ${url.hostname}:443`;
} catch (exception) {
// some exception has occurred.
core.info("Unable to fetch cacheURL");
if (confg.egress_policy === "block") {
core.warning(
"Unable to fetch cacheURL switching egress-policy to audit mode"
);
confg.egress_policy = "audit";
if (isValidEvent()) {
try {
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`);
confg.allowed_endpoints += ` ${url.hostname}:443`;
} catch (exception) {
// some exception has occurred.
core.info("Unable to fetch cacheURL");
if (confg.egress_policy === "block") {
core.info("Switching egress-policy to audit mode");
confg.egress_policy = "audit";
}
}
}

Expand Down

0 comments on commit bac73aa

Please sign in to comment.