Discord Webhook Setup Guide โ
This guide explains how to set up Discord notifications for git pushes to the Lantern repository.
Overview โ
The Lantern repository uses GitHub Actions to automatically send Discord notifications whenever code is pushed to the main or dev branches. These notifications include:
- Branch name
- Commit message
- Author information
- Direct link to the commit
- Timestamp
Step 1: Create a Discord Webhook โ
- Open your Discord server where you want to receive notifications
- Navigate to Server Settings
- Click on the server name dropdown
- Select "Server Settings"
- Go to Integrations
- In the left sidebar, click "Integrations"
- Create a Webhook
- Click "Webhooks" (or "View Webhooks" if you already have some)
- Click "New Webhook" or "Create Webhook"
- Configure the Webhook
- Name:
GitHub Notifications(or any name you prefer) - Channel: Select the channel where you want notifications to appear (e.g.,
#dev-updates,#commits) - Optionally, you can customize the webhook's avatar
- Name:
- Copy the Webhook URL
- Click "Copy Webhook URL"
- Important: Keep this URL secret! Anyone with this URL can send messages to your Discord channel
Step 2: Add the Webhook to GitHub Secrets โ
- Go to your GitHub repository
- Navigate to https://github.com/cattreedev/lantern_app
- Open Settings
- Click the "Settings" tab (you need admin/write access)
- Navigate to Secrets
- In the left sidebar, expand "Secrets and variables"
- Click "Actions"
- Create a New Secret
- Click "New repository secret"
- Name:
DISCORD_WEBHOOK_URL(must be exactly this) - Value: Paste the Discord webhook URL you copied in Step 1
- Click "Add secret"
Step 3: Verify the Setup โ
The workflow is already configured in .github/workflows/discord-notify.yml. To test it:
- Make a test commit to the
devormainbranch - Check the Actions tab on GitHub
- Go to https://github.com/cattreedev/lantern_app/actions
- You should see a "Discord Notification" workflow run
- Check your Discord channel
- A notification should appear with the commit details
Notification Format โ
Main Branch (Blue) โ
When a commit is pushed to main, the notification will have a blue embed color (#5865F2).
Dev Branch (Green) โ
When a commit is pushed to dev, the notification will have a green embed color (#57F287).
Notification Content โ
Each notification includes:
- Repository name
- Branch name
- Commit count (e.g., "1 commit" or "3 commits")
- For each commit:
- Commit author
- Commit SHA (shortened to 7 characters, clickable link)
- Full commit message
- Clickable title that links to the compare view showing all changes
- Timestamp
- Pusher name in the footer
Multiple Commits: When multiple commits are pushed at once, all commits are displayed in a single notification, separated by horizontal rules (---). Each commit shows its own author, SHA, and message.
Troubleshooting โ
Notifications not appearing โ
Check the Actions tab on GitHub to see if the workflow ran
- If it didn't run: Verify the workflow file is in
.github/workflows/and nameddiscord-notify.yml - If it failed: Click on the failed run to see error details
- If it didn't run: Verify the workflow file is in
Verify the secret is set correctly
- The secret name must be exactly
DISCORD_WEBHOOK_URL - The webhook URL should start with
https://discord.com/api/webhooks/
- The secret name must be exactly
Check Discord webhook settings
- Ensure the webhook hasn't been deleted in Discord
- Verify the channel still exists
Workflow not triggering โ
- The workflow only triggers on pushes to
mainordevbranches - Pushes to other branches (e.g., feature branches) won't trigger notifications
- Pull requests don't trigger this workflow
Notification appears but content is wrong โ
- Check the workflow file
.github/workflows/discord-notify.yml - Verify the GitHub Actions context variables are being used correctly
Customization โ
To customize the notifications, edit .github/workflows/discord-notify.yml:
- Change trigger branches: Modify the
branches:list underon: push: - Change colors: Modify the
embed-colorvalue (hex color codes) - Change message format: Modify the
embed-descriptionsection - Add more information: Use GitHub Actions context variables (see GitHub Actions Contexts)
Security Notes โ
- Never commit the webhook URL to the repository
- The webhook URL is stored as a GitHub secret and is not visible in logs
- Only repository administrators can view or modify secrets
- If the webhook URL is compromised, delete it in Discord and create a new one