--
Warning: this code is AI written, as it is for notifications for other projects, this repo stands as it's faster for others.
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 )

