diff options
author | 2024-01-08 07:09:53 -0600 | |
---|---|---|
committer | 2024-01-08 13:09:53 +0000 | |
commit | ff9bd708ae253f93ee61b5f317b4a9d988b89880 (patch) | |
tree | ad801fc427ba601e2da26549db32b9519ff549a1 | |
parent | 5978d77476ee452c778415b4989fc4506c4480ab (diff) | |
download | astro-ff9bd708ae253f93ee61b5f317b4a9d988b89880.tar.gz astro-ff9bd708ae253f93ee61b5f317b4a9d988b89880.tar.zst astro-ff9bd708ae253f93ee61b5f317b4a9d988b89880.zip |
Fix Discord release message (#9626)
* Fix Discord release message
* chore: simplify discord webhook handling
-rw-r--r-- | .github/workflows/release.yml | 11 | ||||
-rwxr-xr-x | scripts/notify/index.js | 22 |
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(); |