-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (35 loc) · 1017 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
37
38
39
40
41
42
const core = require('@actions/core');
const { WebClient } = require('@slack/web-api');
try {
var colorMap = new Map([
["success", "#36a64f"],
["failure", "#ff0000"],
["danger", "#ffc252"]
]);
const token = core.getInput('token');
const channel = core.getInput('channel');
const title = core.getInput('title');
const title_link = core.getInput('title_link');
const text = core.getInput('text');
const attachment_text = core.getInput('attachment_text');
const fields = core.getInput('fields');
const status = core.getInput('status');
const footer = core.getInput('footer');
const web = new WebClient(token);
color = (!!status) ? colorMap.get(status) : "";
web.chat.postMessage({
channel: channel,
text: text,
attachments: [{
fallback: text,
color: color,
title: title,
text: attachment_text,
title_link: title_link,
fields: JSON.parse(fields),
footer: footer
}]
});
} catch (error) {
core.setFailed(error);
}