|
| 1 | +# GitHub-to-Discord Bot Setup Guide |
| 2 | + |
| 3 | +This workflow automatically posts commit information to Discord whenever you push code to GitHub. |
| 4 | + |
| 5 | +## What It Does |
| 6 | + |
| 7 | +✅ Posts commit details to Discord on every push |
| 8 | +✅ Shows commit message, author, branch, and file changes |
| 9 | +✅ Displays stats (files changed, insertions, deletions) |
| 10 | +✅ Provides clickable link to the commit on GitHub |
| 11 | +✅ Formatted with emojis and colors for easy reading |
| 12 | + |
| 13 | +## Setup Instructions |
| 14 | + |
| 15 | +### Step 1: Create a Discord Channel (if you don't have one) |
| 16 | +1. Go to your Discord server |
| 17 | +2. Create a new channel (e.g., `#github-notifications`) |
| 18 | +3. Make sure the bot will have permission to post messages |
| 19 | + |
| 20 | +### Step 2: Create a Discord Webhook |
| 21 | + |
| 22 | +1. **In Discord**, right-click on the channel where you want notifications |
| 23 | +2. Click **"Edit Channel"** |
| 24 | +3. Go to **"Integrations"** → **"Webhooks"** |
| 25 | +4. Click **"New Webhook"** |
| 26 | +5. Give it a name (e.g., "GitHub Bot") |
| 27 | +6. Copy the **Webhook URL** |
| 28 | + |
| 29 | +### Step 3: Add Webhook URL to GitHub Secrets |
| 30 | + |
| 31 | +1. Go to your GitHub repository: https://github.com/Project-XI/Project-EL |
| 32 | +2. Click **Settings** (top right) |
| 33 | +3. Go to **Secrets and variables** → **Actions** |
| 34 | +4. Click **New repository secret** |
| 35 | +5. Name: `DISCORD_WEBHOOK_URL` |
| 36 | +6. Paste the webhook URL you copied from Discord |
| 37 | +7. Click **Add secret** |
| 38 | + |
| 39 | +### Step 4: Test It |
| 40 | + |
| 41 | +1. Make a commit and push to `main`, `develop`, or `master` branch |
| 42 | +2. The GitHub Action will automatically run |
| 43 | +3. You should see a formatted message in your Discord channel within 30 seconds |
| 44 | + |
| 45 | +## Example Discord Message |
| 46 | + |
| 47 | +The bot posts messages that look like: |
| 48 | + |
| 49 | +``` |
| 50 | +📝 New Commit Pushed |
| 51 | +"Refine ORACLE analysis and testing UI" |
| 52 | +
|
| 53 | +🔗 Commit: c2c1c7d |
| 54 | +👤 Author: rajkoli |
| 55 | +🌿 Branch: main |
| 56 | +📊 Stats: Files: 18 | +2442 | -271 |
| 57 | +📄 Changed Files: |
| 58 | +• Docs/index.html |
| 59 | +• backend/.env.example |
| 60 | +• backend/src/agents/oracle.py |
| 61 | +• backend/src/main.py |
| 62 | +• backend/src/cli.py |
| 63 | +``` |
| 64 | + |
| 65 | +## Customization |
| 66 | + |
| 67 | +You can edit `.github/workflows/discord-notify.yml` to: |
| 68 | +- Change which branches trigger notifications (currently: `main`, `develop`, `master`) |
| 69 | +- Modify the message format and colors |
| 70 | +- Add additional fields or remove some |
| 71 | +- Change the webhook timeout or retry logic |
| 72 | + |
| 73 | +## Troubleshooting |
| 74 | + |
| 75 | +| Issue | Solution | |
| 76 | +|-------|----------| |
| 77 | +| No message in Discord | Check that `DISCORD_WEBHOOK_URL` secret is set in GitHub Settings | |
| 78 | +| Webhook URL error | Make sure the webhook URL is correct and not expired | |
| 79 | +| Action fails | Check the GitHub Actions logs: Go to repo → Actions → find the failed run | |
| 80 | +| Webhook URL shows as empty | The secret may have been corrupted; delete and recreate it | |
| 81 | + |
| 82 | +## Security Note |
| 83 | + |
| 84 | +⚠️ **Never** paste your Discord webhook URL in code or commit messages. |
| 85 | +⚠️ Always use GitHub Secrets to store sensitive URLs. |
| 86 | +⚠️ If you accidentally expose a webhook URL, delete it and create a new one in Discord. |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +Once set up, every commit push will automatically notify your team on Discord! 🚀 |
0 commit comments