checking event before saving cache

This commit is contained in:
h0x0er 2022-09-26 22:22:47 +05:30
commit 33f15fc571

View file

@ -4,7 +4,7 @@ import * as core from "@actions/core";
import * as common from "./common";
import isDocker from "is-docker";
import * as cache from "@actions/cache";
import { cacheFile, cacheKey } from "./cache";
import { cacheFile, cacheKey, isValidEvent } from "./cache";
import path from "path";
(async () => {
@ -69,14 +69,16 @@ import path from "path";
console.log("Service log:");
console.log(journalLog);
try {
const cmd = "sudo";
const args = ["cp", path.join(__dirname, "cache.txt"), cacheFile];
cp.execFileSync(cmd, args);
const cacheResult = await cache.saveCache([cacheFile], cacheKey);
console.log(cacheResult);
} catch (exception) {
console.log(exception);
if (isValidEvent()) {
try {
const cmd = "cp";
const args = [path.join(__dirname, "cache.txt"), cacheFile];
cp.execFileSync(cmd, args);
const cacheResult = await cache.saveCache([cacheFile], cacheKey);
console.log(cacheResult);
} catch (exception) {
console.log(exception);
}
}
})();