generated from actions/javascript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (39 loc) · 1.21 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
const core = require('@actions/core');
const got = require('got');
const key = process.env.INPUT_KEY;
const event = process.env.INPUT_EVENT;
const status = process.env.INPUT_STATUS;
const runId = process.env.GITHUB_RUN_ID;
const repo = process.env.GITHUB_REPOSITORY;
const workflow = process.env.GITHUB_WORKFLOW;
async function run() {
if (key === undefined || event === undefined || status === undefined){
return core.setFailed("No key, event or status specified")
}
let title;
let message;
if(status === "success"){
title = `${workflow} succeeded`;
message = `The Workflow ${workflow} on the Repo ${repo} finished without any errors.`
}else if(status === "failure"){
title = `${workflow} failed`;
message = `The Workflow ${workflow} on the Repo ${repo} did not finish without any errors.`
}else{
return core.debug("Invalid status, not running workflow");
}
const url = `https://github.com/${repo}/actions/runs/${runId}`;
try {
const { body } = await got.post(`https://maker.ifttt.com/trigger/${event}/with/key/${key}`, {
json: {
value1: title,
value2: message,
value3: url
}
});
core.debug(body)
} catch (error) {
core.debug(error)
core.setFailed(error.response.body)
}
}
run();