|5 min read|Daniel K., Founder|Guide

Testing GitHub Webhooks Locally: A Complete Guide

You want push events, PR notifications, or deploy triggers from GitHub to hit your local machine. Here's every way to do it.

githubwebhooksdevelopmentci-cd

Why GitHub Webhooks Locally?

Common use cases:

  • CI/CD pipelines that trigger local builds
  • AI agents that respond to code changes
  • Bots that comment on PRs
  • Deploy automation from push events

Method 1: GitHub CLI + Webhook Forwarding

GitHub doesn't have a built-in equivalent to stripe listen, but you can use their REST API to configure webhooks pointing at a tunnel.

Method 2: ngrok + GitHub Webhook

bash
ngrok http 3000
# Copy the URL, e.g. https://abc123.ngrok.io

Then in GitHub repo settings:

  1. Go to Settings > Webhooks > Add webhook
  2. Payload URL: https://abc123.ngrok.io/api/github-webhook
  3. Content type: application/json
  4. Secret: generate a random string
  5. Select events you want

Problem: Free ngrok URLs change every restart. You'll need to update the GitHub webhook config each time.

Method 3: Tryb with Stable Subdomain

python
import tryb

client = tryb.connect(subdomain="my-gh-bot")
# URL is always: https://my-gh-bot.tryb.dev/hook/my-gh-bot

Set the webhook URL once in GitHub. It never changes. If your agent goes offline, events are queued for 24h.

Verifying GitHub Signatures

GitHub signs webhooks with HMAC-SHA256. Always verify:

python
import hmac
import hashlib

def verify_github_signature(payload, signature, secret):
    expected = "sha256=" + hmac.new(
        secret.encode(),
        payload,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, signature)

Or let Tryb's firewall verify it automatically at the relay level.

Common GitHub Webhook Events

EventTrigger
pushCode pushed to any branch
pull_requestPR opened, closed, merged
issuesIssue created or updated
releaseNew release published
workflow_runGitHub Action completed

Ready to secure your agents?

Tryb gives you a firewall, a persistent event queue, and human-in-the-loop approvals. Free tier included -- no credit card required.