This repository has been archived by the owner on Oct 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
62 lines (57 loc) · 1.74 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const core = require("@actions/core");
const github = require("@actions/github");
core.warning("This action is deprecated in favor of https://github.com/maxkomarychev/oction-create-deployment-status")
function parse_array(input_name) {
const input_value = core.getInput(input_name)
if (input_value === "") {
return undefined;
}
if (input_value === "<<EMPTY>>") {
return [];
}
return input_value.split(",");
}
function parse_boolean(input_name) {
const input_value = core.getInput(input_name)
return input_value === "true"
}
function default_parse(input_name) {
const input_value = core.getInput(input_name)
return input_value || undefined
}
try {
const token = default_parse("token");
const deployment_id = default_parse("deployment_id");
const state = default_parse("state");
const log_url = default_parse("log_url");
const description = default_parse("description");
const environment = default_parse("environment");
const environment_url = default_parse("environment_url");
const auto_inactive = parse_boolean("auto_inactive");
const client = new github.GitHub(token);
const context = github.context;
client.repos.createDeploymentStatus({
...context.repo,
token,
deployment_id,
state,
log_url,
description,
environment,
environment_url,
auto_inactive,
headers: {
"Accept": "application/vnd.github.flash-preview+json, application/vnd.github.ant-man-preview+json",
}
}).then(response => {
console.log('response', response)
core.setOutput("id", response.data.id)
})
.catch(error => {
console.log("error 1", error);
core.setFailed(error.message);
});
} catch (error) {
console.log("error 2", error);
core.setFailed(error.message);
}