Send clean Discord notifications when you push to main or other branches when you publish a new release.
- Push notifications with commit message and author
- Release alerts with tag, name, and link
- Uses GitHub Secrets to keep your webhook safe
- press use this template.
- add your DISCORD_WEBHOOK secret in your repo settings with your webhook link inside of it.
- Create a file named
.github/workflows/discord.yml - Paste the following code into it (modify as you wish):
`yaml
name: Discord Notification
on:
push:
branches:
- main
release:
types: [published]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Discord message for push
if: github.event_name == 'push'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"name here-\nπ οΈ New push to *main* by ${{ github.actor }}\nπ [View Commit](${{ github.event.head_commit.url }})\nπ Message: ${{ github.event.head_commit.message }}\"}" \
$DISCORD_WEBHOOK
- name: Send Discord message for release
if: github.event_name == 'release'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"name here-\nπ New release published by ${{ github.actor }}\nπ·οΈ Tag: ${{ github.event.release.tag_name }}\nπ Name: ${{ github.event.release.name }}\nπ [View Release](${{ github.event.release.html_url }})\"}" \
$DISCORD_WEBHOOK
- create a webhook on your discord server either on the web or desktop app.
- Go to your repo β Settings β Secrets β Actions.
- Add a secret named
DISCORD_WEBHOOKwith your Discord webhook URL.
Example of what it should look like when you're done ( minus my logo and repo )
