-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (28 loc) · 857 Bytes
/
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
const core = require("@actions/core");
const fetch = require("node-fetch");
const pick = require('lodash.pick');
const OPTS = {
url: core.getInput("url") || "",
apikey: core.getInput("apikey") || "",
data: core.getInput("data") || "{}"
};
(async () => {
const newrelicArray = [];
console.log(JSON.parse(OPTS.data), 'test');
const parse = JSON.parse(OPTS.data).data;
parse.map(result => {
newrelicArray.push(pick(result, 'rawData').rawData);
});
console.log(newrelicArray);
const res = await fetch(OPTS.url, {
method: 'post',
headers: { 'Content-Type': 'application/json', 'X-Insert-Key': OPTS.apikey },
body: JSON.stringify(newrelicArray)
});
console.log(`Response: ${res.status} ${res.statusText}`);
if (!res.ok) {
core.setFailed(`Reaching webhook failed!`);
return false;
}
return true;
})();