generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.js
47 lines (37 loc) · 1.33 KB
/
index.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
42
43
44
45
46
47
const core = require("@actions/core");
const dotenvAction = require("./dotenv_action");
try {
const ensureExists = core.getInput("ensure-exists").toLowerCase();
const keysCase = core.getInput("keys-case").toLowerCase();
const logVariables = core.getInput("log-variables").toLowerCase();
const maskVariables = core.getInput("mask-variables").toLowerCase();
const exportVariables = core.getInput("export-variables").toLowerCase();
const exportVariablesPrefix = core.getInput("export-variables-prefix");
const path = core.getInput("path");
const variables = dotenvAction({
path: path || ".env",
ensureExists: (ensureExists || "true") === "true",
keysCase: keysCase || "lower",
});
if (maskVariables === "true") {
for (const key in variables) {
const value = variables[key];
core.setSecret(value);
}
}
core.info(
logVariables === "true"
? JSON.stringify(variables, null, 2)
: `Loaded ${Object.keys(variables).length} values into the environment.`,
);
core.setOutput("generic", "please check for actual outputs");
for (const key in variables) {
const value = variables[key];
core.setOutput(key, value);
if (exportVariables === "true") {
core.exportVariable(exportVariablesPrefix + key, value);
}
}
} catch (error) {
core.setFailed(error.message);
}