File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
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))
You can’t perform that action at this time.
0 commit comments