-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (32 loc) · 1.09 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
const core = require('@actions/core');
const github = require('@actions/github');
const sendToTeams = require('./src/ms-teams.js');
const sendToApi = require('./src/api-request.js');
var release = {};
try {
const teamsWebhookUrl = core.getInput('ms-teams-webhook');
const apiEndpoint = core.getInput('api-endpoint');
const apiKey = core.getInput('api-key');
if(!github.context.payload.release) {
console.log('No release found in the payload');
return;
} else {
release = {
repo: github.context.payload.repository.full_name,
title: github.context.payload.release.name,
date: github.context.payload.release.published_at,
notes: github.context.payload.release.body.replace(/\n/g, ' \n\n'),
url: github.context.payload.release.html_url
};
}
if (teamsWebhookUrl) {
console.log('Sending release notes to Teams channel');
sendToTeams(teamsWebhookUrl, release);
}
if (apiEndpoint && apiKey) {
console.log('Sending release notes to API');
sendToApi(apiEndpoint, apiKey, release);
}
} catch (error) {
core.setFailed(error.message);
}