summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yml11
-rwxr-xr-xscripts/notify/index.js22
2 files changed, 20 insertions, 13 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8696c85a0..d25ec07e5 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -62,15 +62,6 @@ jobs:
- name: Generate Notification
id: notification
if: steps.changesets.outputs.published == 'true'
- run: |
- message=$(node scripts/notify/index.js '${{ steps.changesets.outputs.publishedPackages }}')
- echo "message=${message//$'\n'/'%0A'}" >> $GITHUB_OUTPUT
-
- - name: Discord Notification
- if: steps.changesets.outputs.published == 'true'
- id: discord-notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
- uses: Ilshidur/action-discord@0.3.2
- with:
- args: ${{ steps.notification.outputs.message }}
+ run: node scripts/notify/index.js '${{ steps.changesets.outputs.publishedPackages }}'
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();