-
Notifications
You must be signed in to change notification settings - Fork 97
/
save.js
41 lines (37 loc) · 1.17 KB
/
save.js
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
const { saveCache } = require("./cache.js");
const core = require("@actions/core");
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
// throw an uncaught exception. Instead of failing this action, just warn.
process.on("uncaughtException", (e) => {
const warningPrefix = "[warning]";
core.info(`${warningPrefix}${e.message}`);
});
// Added early exit to resolve issue with slow post action step:
// - https://github.com/actions/setup-node/issues/878
// https://github.com/actions/cache/pull/1217
async function run(earlyExit) {
try {
const cacheInput = core.getBooleanInput("cache");
if (cacheInput) {
await saveCache();
} else {
core.info("Cache not requested, not saving cache");
}
if (earlyExit) {
process.exit(0);
}
} catch (error) {
let message = "Unknown error!";
if (error instanceof Error) {
message = error.message;
}
if (typeof error === "string") {
message = error;
}
core.warning(message);
}
}
if (require.main === module) {
run(true);
}