Public
Store GitHub webhooks in SQLite; add collaborator on repo create
githubsqlitewebhook
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

GitHub Webhook Collaborator

Receives GitHub webhooks and:

  • Default case — stores every webhook in a SQLite table (webhooks) and acknowledges it with 200 OK.
  • Special case — when a new repository is created (repository event, action: created), automatically adds a configured collaborator to that repository via the GitHub API.

The webhook endpoint is live at:

https://github-webhook-collab.val.run/

Setup

1. Configure environment variables

Set these on the val:

  • GITHUB_WEBHOOK_SECRET — a high-entropy secret used to verify webhook signatures. Set the same value on GitHub (Step 2). Optional but strongly recommended; without it the endpoint trusts any payload.
  • COLLABORATOR — the GitHub username to add as a collaborator on newly created repositories.
  • GITHUB_TOKEN — a token that can invite collaborators to owners repos. Use a classic PAT with repo admin scope, or a fine-grained PAT granted Administration → Read and write on the relevant repositories.

👉 Add GITHUB_WEBHOOK_SECRET here: https://www.val.town/x/heidi/github-webhook-collaborator/environment-variables?key=GITHUB_WEBHOOK_SECRET 👉 Add COLLABORATOR here: https://www.val.town/x/heidi/github-webhook-collaborator/environment-variables?key=COLLABORATOR 👉 Add GITHUB_TOKEN here: https://www.val.town/x/heidi/github-webhook-collaborator/environment-variables?key=GITHUB_TOKEN

2. Create the webhook on GitHub

  1. Go to your repo (or org) → Settings → Webhooks → Add webhook.
  2. Payload URL: your val's endpoint https://github-webhook-collab.val.run/
  3. Content type: application/json.
  4. Secret: the same GITHUB_WEBHOOK_SECRET value.
  5. Which events: select Repositories (delivers the repository webhook). For broader logging of all events, select "Send me everything".
  6. Save.

How it works

  • The default path writes each event to SQLite so you keep a complete audit trail.
  • repository + created events trigger the collaborator invite. The collaborator is granted write permission.

Files

  • main.ts — HTTP handler: verifies signature, stores the event, routes the repository-created case.
  • db.ts — SQLite schema and insert helper.
  • github.ts — calls the GitHub API to add a collaborator.