ci: fix Discord release notification step
This commit is contained in:
@@ -447,10 +447,58 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Send release to Discord
|
- name: Send release to Discord
|
||||||
uses: SethCohen/github-releases-to-discord@v1
|
if: ${{ secrets.DISCORD_WEBHOOK_URL != '' }}
|
||||||
with:
|
env:
|
||||||
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
color: "2105893"
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
username: "OpenChamber Releases"
|
VERSION: ${{ needs.create-release.outputs.version }}
|
||||||
footer_title: "OpenChamber Changelog"
|
REPOSITORY: ${{ github.repository }}
|
||||||
reduce_headings: true
|
run: |
|
||||||
|
node - <<'NODE'
|
||||||
|
(async () => {
|
||||||
|
const tag = `v${process.env.VERSION}`;
|
||||||
|
const repo = process.env.REPOSITORY;
|
||||||
|
|
||||||
|
const releaseRes = await fetch(`https://api.github.com/repos/${repo}/releases/tags/${tag}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
|
||||||
|
Accept: 'application/vnd.github+json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!releaseRes.ok) {
|
||||||
|
const body = await releaseRes.text();
|
||||||
|
throw new Error(`Failed to fetch release ${tag}: ${releaseRes.status} ${body}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const release = await releaseRes.json();
|
||||||
|
const description = (release.body || `OpenChamber ${tag} released.`).slice(0, 4096);
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
username: 'OpenChamber Releases',
|
||||||
|
embeds: [
|
||||||
|
{
|
||||||
|
title: release.name || `OpenChamber ${tag}`,
|
||||||
|
url: release.html_url,
|
||||||
|
description,
|
||||||
|
color: 2105893,
|
||||||
|
footer: { text: 'OpenChamber Changelog' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const discordRes = await fetch(process.env.DISCORD_WEBHOOK_URL, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'content-type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!discordRes.ok) {
|
||||||
|
const body = await discordRes.text();
|
||||||
|
throw new Error(`Failed to send Discord release: ${discordRes.status} ${body}`);
|
||||||
|
}
|
||||||
|
})().catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
NODE
|
||||||
|
|||||||
Reference in New Issue
Block a user