-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
62 lines (58 loc) · 1.56 KB
/
build.ts
File metadata and controls
62 lines (58 loc) · 1.56 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
51
52
53
54
55
56
57
58
59
60
61
62
import { getInput, setFailed, setOutput } from "@actions/core";
import { getBool, makeClient, parseDeployOutput } from "./lib.js";
interface Inputs {
project: string;
image: string;
capsule: string;
skipImageCheck: boolean;
deploy: boolean;
environment: string;
dryRun: boolean;
force: boolean;
}
async function action(inputs: Inputs) {
if (inputs.deploy && inputs.environment == "") {
throw new Error("deploy was true, but environment not given.");
}
const client = await makeClient();
let response = await client.build.create({
skipImageCheck: inputs.skipImageCheck,
image: inputs.image,
capsuleId: inputs.capsule,
projectId: inputs.project,
});
setOutput("build", response.buildId);
if (inputs.deploy) {
let resp = await client.capsule.deploy({
projectId: inputs.project,
environmentId: inputs.environment,
capsuleId: inputs.capsule,
dryRun: inputs.dryRun,
force: inputs.force,
changes: [
{
field: {
case: "buildId",
value: response.buildId,
},
},
],
});
let output = parseDeployOutput(resp.resourceYaml);
setOutput("rolloutConfig", output);
}
}
try {
action({
project: getInput("project"),
image: getInput("image"),
capsule: getInput("capsule"),
environment: getInput("environment"),
skipImageCheck: getInput("skipImageCheck") === "true" ? true : false,
deploy: getBool("deploy"),
dryRun: getBool("dryRun"),
force: getBool("force"),
});
} catch (e: any) {
setFailed(e.message);
}