mirror of
https://github.com/step-security/harden-runner.git
synced 2026-06-06 00:17:06 +00:00
checking event before saving cache
This commit is contained in:
parent
1670e27193
commit
33f15fc571
1 changed files with 11 additions and 9 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue