-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (49 loc) · 1.61 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
const core = require('@actions/core');
const github = require('@actions/github');
const request = require('request');
try {
const baseUrl = core.getInput('url');
const token = core.getInput('token');
const tokenStr = typeof token === 'undefined' ? "" : "?token=" + token;
const url = baseUrl + github.context.repo.owner + "/"
+ github.context.repo.repo + "/commit/" + github.context.sha + tokenStr ;
console.log(`Starting run...`);
let result = "success";
request.post(url, (err, response, body) => {
var jBody;
try {
jBody = JSON.parse(body);
} catch (err) {
core.notice(body);
core.setFailed("There was a problem with your run");
core.error();
}
if(jBody.status === "Success") {
core.info("Run succeded!");
core.info("The following packages were built:");
} else {
core.notice("Run failed!");
core.info("The following packages were built or attempted:");
}
for (var sys in jBody.packages) {
core.startGroup(`System "${sys}"`);
let pkgs = (jBody.packages)[sys]
for (var pkg in pkgs) {
let groupName = pkgs[pkg].status === "Success" ?
`Package "${pkg}" succeeded!` :
`Package "${pkg}" failed!`
core.startGroup(groupName);
if (pkgs[pkg].logs === null) {
core.info("No logs available");
} else {
core.info("Logs:");
core.info(pkgs[pkg].logs);
}
core.endGroup();
}
core.endGroup();
}
})
} catch (error) {
core.setFailed(error.message);
}