-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Discord Release Notifications | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
run_main: | ||
runs-on: ubuntu | ||
name: Send a release notification to Discord | ||
steps: | ||
- uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { payload } = context; | ||
if (!["released"].includes(payload.action)) return | ||
const { name, tag_name, body, html_url: url } = context.release | ||
const regex = /Thanks \[@\S+\]\(\S+\)!(.*)$/gm | ||
const isRootPkg = !tag_name.startsWith("@") && !body.includes("Thanks") | ||
// Send a message to Discord | ||
const message = { | ||
embeds: [ | ||
{ | ||
title: `Release - ${name}`, | ||
description: isRootPkg | ||
? "Automatically updated to include recent changes to other SDK submodules" | ||
: Array.from(body.matchAll(regex)).map(match => match[1]).join("\n\n"), | ||
url, | ||
color: 5832543, | ||
} | ||
} | ||
fetch("https://discord.com/api/webhooks/${{ secrets.DISCORD_WEBHOOK_ID }}/${{ secrets.DISCORD_WEBHOOK_TOKEN }}", { | ||
method: "POST", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify(message), | ||
}) | ||
.then((res) => res.text()) | ||
.then((text) => console.log(text)) | ||
.catch((err) => console.error(err)) | ||
- name: Sending message | ||
uses: nhevia/discord-styled-releases@main | ||
with: | ||
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} | ||
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} |