Skip to content

Commit

Permalink
actions: Create script to announce a new release via a Discord WebHooks
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser authored and TellowKrinkle committed Nov 2, 2021
1 parent 6eacade commit c32d5f1
Show file tree
Hide file tree
Showing 4 changed files with 864 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
*.md
40 changes: 40 additions & 0 deletions .github/workflows/scripts/releases/announce-release/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { MessageEmbed, WebhookClient } from "discord.js";
import * as github from '@actions/github';

const assets = github.context.payload.release.assets;
let windowsAssetLinks = "";
let linuxAssetLinks = "";

for (var i = 0; i < assets.length; i++) {
let asset = assets[i];
if (asset.name.includes("symbols")) {
continue;
}
if (asset.name.includes("windows")) {
windowsAssetLinks += `- [${asset.name}](${asset.browser_download_url})\n`
} else if (asset.name.includes("linux")) {
linuxAssetLinks += `- [${asset.name}](${asset.browser_download_url})\n`
}
}

// Publish Webhook
const embed = new MessageEmbed()
.setColor('#FF8000')
.setTitle('New PCSX2 Nightly Build Available!')
.addFields(
{ name: 'Version', value: github.context.payload.release.tag_name, inline: true },
{ name: 'Release Link', value: `[Github Release](${github.context.payload.release.html_url})`, inline: true },
{ name: 'Installation Steps', value: '[See Here](https://github.com/PCSX2/pcsx2/wiki/Nightly-Build-Usage-Guide)', inline: true }
);

if (windowsAssetLinks != "") {
embed.addField('Windows Downloads', windowsAssetLinks, false);
}
if (linuxAssetLinks != "") {
embed.addField('Linux Downloads', linuxAssetLinks, false);
}

const webhookClient = new WebhookClient({ url: process.env.DISCORD_BUILD_WEBHOOK });
await webhookClient.send({
embeds: [embed],
});
Loading

0 comments on commit c32d5f1

Please sign in to comment.