Files
basecoat/.github/workflows/discord-release.yml
T

52 lines
1.6 KiB
YAML

name: Announce release on Discord
on:
release:
types: [published]
permissions: {}
jobs:
announce:
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- name: Send Discord announcement
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
RELEASE_NAME: ${{ github.event.release.name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.release.html_url }}
RELEASE_BODY: ${{ github.event.release.body }}
REPO: ${{ github.repository }}
run: |
test -n "$DISCORD_WEBHOOK_URL"
jq -n \
--arg repo "$REPO" \
--arg name "$RELEASE_NAME" \
--arg tag "$RELEASE_TAG" \
--arg url "$RELEASE_URL" \
--arg body "$RELEASE_BODY" \
'($body | if length > 1500 then .[:1500] + "...\n\n[Read more](" + $url + ")" else . end) as $description |
{
username: "Basecoat Releases",
allowed_mentions: { parse: [] },
embeds: [{
title: ($repo + " " + $tag),
url: $url,
description: ((if $name != "" then "**" + $name + "**\n\n" else "" end) + $description),
color: 5793266
}]
}' > payload.json
curl --fail-with-body \
--retry 3 \
--retry-all-errors \
--retry-delay 2 \
-H "Content-Type: application/json" \
-X POST \
-d @payload.json \
"$DISCORD_WEBHOOK_URL"