-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
71 lines (58 loc) · 2.06 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
63
64
65
66
67
68
const axios = require('axios').default;
const core = require('@actions/core');
const github = require('@actions/github');
try {
const containerID = core.getInput('container-id');
const imageRegistryID = core.getInput('image-registry-id');
const channel = core.getInput('channel');
const updateType = core.getInput('update-type');
const token = core.getInput('token');
const payload = github.context.payload
const domain = core.getInput('domain');
const imageName = core.getInput('image-name');
const tag = core.getInput('tag');
const projectId = core.getInput('project-id');
const organizationId = core.getInput('org-id');
const organizationId = core.getInput('debug');
if (debug){
console.log(`debug enabled...`);
}
console.log(`Sending Request to Platformer API....`);
const body = {
channel,
update_type: updateType,
image: imageName,
tag: tag
}
let WebhhookURL;
if (containerID && containerID != "") {
body.container_id = containerID
WebhhookURL = `${domain}/rudder/webhook/v1/container`
}
if (imageRegistryID && imageRegistryID != "") {
body.image_registry_id = imageRegistryID
WebhhookURL = `${domain}/rudder/webhook/v1/image-registry`
}
const headers = {
'Content-Type': 'application/json',
'Authorization': token,
'x-project-id': projectId,
'x-organization-id': organizationId
}
if (debug){
console.log("request-body: ", JSON.stringify(body));
console.log("request-headers: ", JSON.stringify(headers));
}
console.log("sending request to " + WebhhookURL)
axios.post(WebhhookURL, body, {
headers: headers
}).then(function (response) {
core.setOutput("platformer-status", "deployed");
}).catch(function (error) {
core.setOutput("platformer-status", "failed");
core.setFailed(error.message);
});
} catch (error) {
core.setOutput("platformer-status", "failed");
core.setFailed(error.message);
}