summaryrefslogtreecommitdiff
path: root/scripts/notify/index.js
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2024-01-08 07:09:53 -0600
committerGravatar GitHub <noreply@github.com> 2024-01-08 13:09:53 +0000
commitff9bd708ae253f93ee61b5f317b4a9d988b89880 (patch)
treead801fc427ba601e2da26549db32b9519ff549a1 /scripts/notify/index.js
parent5978d77476ee452c778415b4989fc4506c4480ab (diff)
downloadastro-ff9bd708ae253f93ee61b5f317b4a9d988b89880.tar.gz
astro-ff9bd708ae253f93ee61b5f317b4a9d988b89880.tar.zst
astro-ff9bd708ae253f93ee61b5f317b4a9d988b89880.zip
Fix Discord release message (#9626)
* Fix Discord release message * chore: simplify discord webhook handling
Diffstat (limited to 'scripts/notify/index.js')
-rwxr-xr-xscripts/notify/index.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/notify/index.js b/scripts/notify/index.js
index d215e9eed..f42c1b321 100755
--- a/scripts/notify/index.js
+++ b/scripts/notify/index.js
@@ -94,7 +94,7 @@ async function generatePackageMap() {
);
}
-async function run() {
+async function generateMessage() {
await generatePackageMap();
const releases = process.argv.slice(2)[0];
const data = JSON.parse(releases);
@@ -145,15 +145,31 @@ async function run() {
}
if (message.length < 2000) {
- console.log(message);
+ return message;
} else {
message = `${emoji} Some ${descriptor} ${pluralize(verb)}\n\n`;
message += `• \`${name}@${version}\` Read the [release notes →](<${url}>)\n`;
message += `\n\nAlso ${item(extraVerbs)}: ${remainingPackages.length} other packages!`;
- console.log(message);
+ return message;
}
}
}
+async function run() {
+ if (!process.env.DISCORD_WEBHOOK) {
+ console.error('No DISCORD_WEBHOOK variable detected!');
+ process.exit(1);
+ }
+ const content = await generateMessage();
+
+ await fetch(JSON.stringify({ content }), {
+ url: `${process.env.DISCORD_WEBHOOK}?wait=true`,
+ method: 'POST',
+ headers: {
+ 'content-type': 'application/json'
+ }
+ })
+}
+
run();