Skip to content

Discord Webhook Configuration โ€‹

This guide explains how to set up separate Discord webhooks for commits vs. deployments.

Why Separate Webhooks? โ€‹

  • Commits channel (#commits): Shows all pushes to main/dev branches
  • Deployments channel (#deployments): Shows deployment status (success/failure) to staging and production

This separation reduces noise and makes it easier to track what's deployed vs. what's committed.

Setup Instructions โ€‹

1. Create Discord Channels โ€‹

In your Discord server:

  1. Create two new channels:

    • #commits (Private to team)
    • #deployments (Private to team)
  2. Set channel permissions (optional but recommended):

    • Make channels read-only for regular members
    • Only webhook bot can post

2. Create Webhooks โ€‹

For each channel:

  1. Settings โ†’ Integrations โ†’ Webhooks
  2. Click New Webhook
  3. Name it (e.g., "Lantern GitHub Bot")
  4. Select the channel
  5. Click Copy Webhook URL

Result:

#commits channel โ†’ DISCORD_WEBHOOK_COMMITS
#deployments channel โ†’ DISCORD_WEBHOOK_DEV_DEPLOY, DISCORD_WEBHOOK_PROD_DEPLOY

3. Add Secrets to GitHub โ€‹

In GitHub repository:

  1. Go to Settings โ†’ Secrets and variables โ†’ Actions
  2. Click New repository secret

Add these secrets:

DISCORD_WEBHOOK_COMMITS
โ”œโ”€ URL from #commits webhook

DISCORD_WEBHOOK_DEV_DEPLOY
โ”œโ”€ URL from #deployments webhook (used for dev.ourlantern.app)

DISCORD_WEBHOOK_PROD_DEPLOY
โ”œโ”€ URL from #deployments webhook (used for ourlantern.app)

Note: DISCORD_WEBHOOK_DEV_DEPLOY and DISCORD_WEBHOOK_PROD_DEPLOY can point to the same Discord channel if you prefer, or different channels for separation.

Webhook URLs Format โ€‹

Each webhook URL looks like:

https://discordapp.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN

โš ๏ธ Keep these secret! Never commit to git or share publicly.

Deprecation โ€‹

The old DISCORD_WEBHOOK_URL secret is deprecated and should be removed after migration:

  1. Delete from GitHub Secrets
  2. Verify all workflows use the new secrets
  3. Remove any references from documentation

Testing Webhooks โ€‹

To test a webhook manually:

bash
curl -X POST https://discordapp.com/api/webhooks/YOUR_ID/YOUR_TOKEN \
  -H 'Content-Type: application/json' \
  -d '{
    "username": "Test Bot",
    "content": "Test message from GitHub Actions"
  }'

Expected response: 204 No Content (success)

Troubleshooting โ€‹

Webhook returns 404 โ€‹

  • Webhook URL is incorrect or expired
  • Channel was deleted
  • Fix: Create a new webhook and update the secret

Webhook returns 401 โ€‹

  • Webhook token is invalid or revoked
  • Fix: Recreate the webhook

Messages not appearing โ€‹

  • Check webhook is in correct channel
  • Verify bot has permission to post in channel
  • Check Discord server notifications aren't muted

Rate limiting (429) โ€‹

  • Too many requests to Discord API
  • GitHub Actions is sending too many notifications
  • Fix: Batch multiple commits in one message (already implemented)

See Also โ€‹

Built with VitePress