Skip to content

Commit

Permalink
test 10
Browse files Browse the repository at this point in the history
  • Loading branch information
apathania22 committed Jun 15, 2024
1 parent 213f6e3 commit 8ab420e
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion scripts/teams-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
*/
function transformPayload(payload) {
console.log("payload", payload);

const title = `JSS Release ${payload.tag_name}`;
const releaseUrl = payload.html_url;
const publishedBy = payload.author.login;

const teamsPayload = {
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
themeColor: "0076D7",
title: title,
text: `**Release:** ${releaseUrl}\n\n**Published by:** ${publishedBy}}`,
};
return teamsPayload;
}

(async () => {
Expand All @@ -14,5 +27,16 @@ function transformPayload(payload) {
return;
}

transformPayload(github.event);
try {
await fetch(process.env.TEAMS_WEBHOOK_URL, {
method: "POST",
body: JSON.stringify({
...transformPayload(github.event.release),
}),
});
} catch (error) {
// TODO: add better log message
console.log("Error occurred ", error);
process.exit(1);
}
})();

0 comments on commit 8ab420e

Please sign in to comment.