forked from stupidloud/cachewrtbuild
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathutils.js
More file actions
50 lines (44 loc) · 1.61 KB
/
utils.js
File metadata and controls
50 lines (44 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as core from "@actions/core";
import { execSync } from "node:child_process";
import path from "node:path";
export function buildBaseConfig() {
const prefix = core.getInput("prefix");
if (prefix) {
process.chdir(prefix);
core.debug(`Changed working directory to: ${prefix}`);
}
const mixkey = core.getInput("mixkey");
let keyString = mixkey ? `${mixkey}-cache-openwrt` : "cache-openwrt";
const paths = [];
const cacheToolchain = core.getBooleanInput("toolchain");
if (cacheToolchain) {
let toolchainHash = "";
try {
toolchainHash = execSync('git log --pretty=tformat:"%h" -n1 tools toolchain')
.toString()
.trim();
} catch {
// fall through to the empty-hash warning below
}
if (toolchainHash) {
keyString += `-${toolchainHash}`;
} else {
core.warning(
"Could not determine toolchain hash from git log " +
"(tools/toolchain may have no commits, the clone may be shallow, " +
"or no .git directory is present). " +
"Cache key will not include a toolchain-specific hash."
);
}
paths.push(
path.join("staging_dir", "host*"),
path.join("staging_dir", "tool*")
);
}
const cacheCcache = core.getBooleanInput("ccache");
const otherPaths = core.getMultilineInput("extra_paths").filter(Boolean);
if (otherPaths.length > 0) {
paths.push(...otherPaths);
}
return { keyString, paths, cacheToolchain, cacheCcache };
}