-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
47 lines (46 loc) · 1.48 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 github = require("@actions/github");
const { exec } = require("child_process");
try {
const appcenterToken = core.getInput("appcenter-token");
const deploymentName = core.getInput("deployment-name");
const appName = core.getInput("app-name");
exec(
`appcenter login --token ${appcenterToken}`,
function (error, stdout, stderr) {
if (error) {
core.setFailed(error);
return;
}
exec(
`appcenter codepush deployment list --app ${appName} --output json`,
function (error, stdout, stderr) {
if (error) {
core.setFailed(error);
return;
}
const deployments = JSON.parse(stdout);
const selectedDeployment = deployments.find(
(deployment) => deployment.name === deploymentName
);
if (!selectedDeployment) {
core.setFailed(
`Not found deployment with "${deploymentName}" name`
);
return;
}
core.setOutput("key", selectedDeployment.key);
core.setOutput("name", selectedDeployment.name);
core.setOutput("version", selectedDeployment.latestRelease.label);
core.setOutput(
"mandatory",
selectedDeployment.latestRelease.isMandatory
);
core.setOutput("json", JSON.stringify(selectedDeployment));
}
);
}
);
} catch (error) {
core.setFailed(error.message);
}