ci: Discord notification workflow for releases

When a new release is published, a Github Action workflow kicks off that
sends a customized notification to Discord.
recyclarr
Robert Dailey 4 years ago
parent b8cad7b873
commit 638e3d353b

@ -0,0 +1,21 @@
name: Release Notification
on:
release:
types: [published]
jobs:
notify:
name: Discord Notification
runs-on: ubuntu-latest
steps:
- run: wget https://raw.githubusercontent.com/rcdailey/trash-updater/master/ci/notify/discord_notify.py
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- run: pip install discord-webhook
- run: |
python discord_notify.py \
"${{ github.event.release.tag_name }}" \
"${{ secrets.DISCORD_WEBHOOK }}" \
"${{ github.event.release.body }}"

@ -0,0 +1,48 @@
from discord_webhook import DiscordWebhook, DiscordEmbed
import sys
version = sys.argv[1]
if not version:
print('Pass version as first argument')
exit(1)
webhook_url = sys.argv[2]
if not webhook_url:
print('Pass webhook URL as second argument')
exit(1)
changelog = sys.argv[3]
if not changelog:
print('Pass changelog as third argument')
exit(1)
mkdown_desc = f'''
**Release Notes**
```
{changelog}
```
'''
embed = DiscordEmbed(
title=f'New Release {version}',
description=mkdown_desc,
url=f'https://github.com/rcdailey/trash-updater/releases/tag/{version}'
)
embed.set_author(
name='Trash Updater',
url='https://github.com/rcdailey/trash-updater',
icon_url='https://github.com/rcdailey/trash-updater/blob/master/ci/notify/trash-icon.png?raw=true')
embed.add_embed_field(name='Linux (x64)',
value=f'[Download](https://github.com/rcdailey/trash-updater/releases/download/{version}/trash-linux-x64.zip)')
embed.add_embed_field(name='Windows (x64)',
value=f'[Download](https://github.com/rcdailey/trash-updater/releases/download/{version}/trash-win-x64.zip)')
embed.add_embed_field(name='MacOS (x64)',
value=f'[Download](https://github.com/rcdailey/trash-updater/releases/download/{version}/trash-osx-x64.zip)')
webhook = DiscordWebhook(webhook_url)
webhook.add_embed(embed)
print(webhook.execute())

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Loading…
Cancel
Save