2021-10-18 04:15:45 +00:00
|
|
|
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")) {
|
2021-11-03 23:42:14 +00:00
|
|
|
let friendlyName = asset.name;
|
|
|
|
try {
|
|
|
|
friendlyName = asset.name.split("windows-")[1].split(".7z")[0].replace("-", " ");
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
windowsAssetLinks += `- [${friendlyName}](${asset.browser_download_url})\n`
|
2021-10-18 04:15:45 +00:00
|
|
|
} else if (asset.name.includes("linux")) {
|
2021-11-03 23:42:14 +00:00
|
|
|
let friendlyName = asset.name;
|
|
|
|
try {
|
|
|
|
friendlyName = asset.name.split("linux-")[1].split(".AppImage")[0].replace("-", " ");
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
linuxAssetLinks += `- [${friendlyName}](${asset.browser_download_url})\n`
|
2021-10-18 04:15:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 },
|
2021-11-03 23:42:14 +00:00
|
|
|
{ name: 'Installation Steps', value: '[See Here](https://github.com/PCSX2/pcsx2/wiki/Nightly-Build-Usage-Guide)', inline: true },
|
|
|
|
{ name: 'Included Changes', value: github.context.payload.release.body, inline: false }
|
2021-10-18 04:15:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
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],
|
|
|
|
});
|