Skip to content

Commit e03eef0

Browse files
committed
ci: add discord release workflow
1 parent 4fb97ca commit e03eef0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/discord.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Discord Release Notifications
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
run_main:
10+
runs-on: ubuntu-latest
11+
name: Send a release notification to Discord
12+
steps:
13+
- uses: actions/github-script@v7
14+
with:
15+
script: |
16+
const { payload } = context;
17+
if (payload.action !== "created") return
18+
19+
const { name, tag_name, body, html_url: url } = payload.release
20+
21+
const regex = /Thanks \[@\S+\]\(\S+\)!(.*)$/gm
22+
const isRootPkg = !tag_name.startsWith("@") && !body.includes("Thanks")
23+
24+
const message = {
25+
embeds: [
26+
{
27+
title: `Release - ${name}`,
28+
description: isRootPkg
29+
? "Automatically updated to include recent changes to other SDK submodules"
30+
: Array.from(body.matchAll(regex)).map(match => match[1]).join("\n\n"),
31+
url,
32+
color: 3447003,
33+
}
34+
]
35+
}
36+
37+
fetch("https://discord.com/api/webhooks/${{ secrets.DISCORD_WEBHOOK_ID }}/${{ secrets.DISCORD_WEBHOOK_TOKEN }}", {
38+
method: "POST",
39+
headers: { "Content-Type": "application/json" },
40+
body: JSON.stringify(message),
41+
})
42+
.then((res) => res.text())
43+
.then((text) => console.log(text))

0 commit comments

Comments
 (0)