|
| 1 | +# Receiving GitHub Webhooks Locally |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +- Docker Compose |
| 6 | +- A GitHub App (org or personal) — the app's webhook delivers events from every |
| 7 | + repo where it's installed, so you configure the URL once |
| 8 | + |
| 9 | +## 1. Generate a webhook secret |
| 10 | + |
| 11 | +```bash |
| 12 | +openssl rand -hex 32 |
| 13 | +``` |
| 14 | + |
| 15 | +Save the output — you'll use it in both GitHub and the local stack. |
| 16 | + |
| 17 | +## 2. Create a smee.io channel |
| 18 | + |
| 19 | +Go to [smee.io](https://smee.io) and click **Start a new channel**. Copy the |
| 20 | +channel URL (e.g. `https://smee.io/abc123`). |
| 21 | + |
| 22 | +## 3. Configure your GitHub App |
| 23 | + |
| 24 | +1. Go to **Settings → Developer settings → GitHub Apps** |
| 25 | +2. Select your app (or create a new one) |
| 26 | +3. Under **Webhook**: |
| 27 | + - **Webhook URL**: your smee.io channel URL |
| 28 | + - **Webhook secret**: the secret you generated in step 1 |
| 29 | +4. Under **Permissions & events**, subscribe to the events you need |
| 30 | +5. Install the app on the repositories or organization you want to receive |
| 31 | + events from |
| 32 | + |
| 33 | +## 4. Start the stack |
| 34 | + |
| 35 | +```bash |
| 36 | +SMEE_URL=https://smee.io/abc123 \ |
| 37 | +GITHUB_WEBHOOK_SECRET=<secret-from-step-1> \ |
| 38 | +docker compose --profile dev up |
| 39 | +``` |
| 40 | + |
| 41 | +This starts NATS, the webhook receiver, and the smee client. The smee client |
| 42 | +connects to your channel and forwards events to the webhook receiver. |
| 43 | + |
| 44 | +Without `--profile dev`, the smee client is excluded and only the core services |
| 45 | +start. |
| 46 | + |
| 47 | +## 5. Verify |
| 48 | + |
| 49 | +Trigger an event in a repository where the app is installed (e.g. push a |
| 50 | +commit). You should see: |
| 51 | + |
| 52 | +- The event appear on your smee.io channel page |
| 53 | +- The smee client forward it to the webhook receiver |
| 54 | +- The webhook receiver publish it to NATS on `github.{event}` |
| 55 | + |
| 56 | +## Environment variables |
| 57 | + |
| 58 | +| Variable | Required | Default | Description | |
| 59 | +|---|---|---|---| |
| 60 | +| `GITHUB_WEBHOOK_SECRET` | yes | — | HMAC-SHA256 secret (must match GitHub App) | |
| 61 | +| `SMEE_URL` | yes (dev profile) | — | smee.io channel URL | |
| 62 | +| `GITHUB_WEBHOOK_PORT` | no | `8080` | HTTP port for the webhook receiver | |
| 63 | +| `GITHUB_SUBJECT_PREFIX` | no | `github` | NATS subject prefix | |
| 64 | +| `GITHUB_STREAM_NAME` | no | `GITHUB` | JetStream stream name | |
| 65 | +| `RUST_LOG` | no | `info` | Log level | |
0 commit comments