mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix Discord release message (#9626)
* Fix Discord release message * chore: simplify discord webhook handling
This commit is contained in:
parent
5978d77476
commit
ff9bd708ae
2 changed files with 20 additions and 13 deletions
11
.github/workflows/release.yml
vendored
11
.github/workflows/release.yml
vendored
|
@ -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 }}'
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue