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
|
- name: Generate Notification
|
||||||
id: notification
|
id: notification
|
||||||
if: steps.changesets.outputs.published == 'true'
|
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:
|
env:
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
uses: Ilshidur/action-discord@0.3.2
|
run: node scripts/notify/index.js '${{ steps.changesets.outputs.publishedPackages }}'
|
||||||
with:
|
|
||||||
args: ${{ steps.notification.outputs.message }}
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ async function generatePackageMap() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function generateMessage() {
|
||||||
await generatePackageMap();
|
await generatePackageMap();
|
||||||
const releases = process.argv.slice(2)[0];
|
const releases = process.argv.slice(2)[0];
|
||||||
const data = JSON.parse(releases);
|
const data = JSON.parse(releases);
|
||||||
|
@ -145,15 +145,31 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.length < 2000) {
|
if (message.length < 2000) {
|
||||||
console.log(message);
|
return message;
|
||||||
} else {
|
} else {
|
||||||
message = `${emoji} Some ${descriptor} ${pluralize(verb)}\n\n`;
|
message = `${emoji} Some ${descriptor} ${pluralize(verb)}\n\n`;
|
||||||
message += `• \`${name}@${version}\` Read the [release notes →](<${url}>)\n`;
|
message += `• \`${name}@${version}\` Read the [release notes →](<${url}>)\n`;
|
||||||
|
|
||||||
message += `\n\nAlso ${item(extraVerbs)}: ${remainingPackages.length} other packages!`;
|
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();
|
run();
|
||||||
|
|
Loading…
Reference in a new issue