Skip to Content
upserve

Release webhooks

Refresh a GitHub application after authenticated release events.

A webhook makes newly published releases available without waiting for the next expired-cache request. GitHub sends a signed event, and Upserve verifies it before refreshing the application's release list.

Configure the secret

Generate a long random secret and store it in both your server environment and GitHub's webhook configuration. Don't commit it.

upserve.config.ts
import { defineConfig } from "@neplex/upserve";
import { github } from "@neplex/upserve-github";
import { generic } from "@neplex/upserve-generic";

const webhookSecret = process.env.GITHUB_WEBHOOK_SECRET;

if (!webhookSecret) throw new Error("GITHUB_WEBHOOK_SECRET is required");

export default defineConfig({
  apps: {
    editor: {
      provider: github({ repository: "owner/editor", webhookSecret }),
      adapters: [generic()],
    },
  },
});

This example assumes a public repository. Add repository credentials and downstream authorization separately if needed.

Add the GitHub webhook

In your repository's Settings → Webhooks, create a webhook with:

SettingValue
Payload URLhttps://updates.example.com/webhooks/editor
Content typeapplication/json
SecretThe value of GITHUB_WEBHOOK_SECRET
EventsRelease events

Replace the host and application ID. If Upserve is mounted at /updates, use /updates/webhooks/editor instead.

Upserve verifies the HMAC-SHA256 signature, the release event type and repository.full_name. It accepts release events regardless of their action and refreshes from GitHub rather than trusting the event's release data.

Test a delivery

Use GitHub's webhook delivery history to inspect a real event or redeliver a signed release event. When the refresh completes before the response, Upserve returns 200:

{ "accepted": true, "refreshed": true }

A missing or incorrect signature, wrong repository or unsupported event type returns 401 and never schedules a refresh. GitHub's initial ping event isn't a release event, so it also returns 401. That doesn't mean release signature verification is broken. Bodies are limited to 256 KiB; a larger body returns 422 before verification.

Bursts of release events

Publishing a release commonly sends several events within a second, for example edited, published and released. Every authenticated event is accepted; none is rejected for arriving too soon. Upserve coalesces them per application:

  1. The first event starts a forced refresh of the release list and provider pages.

  2. Events that arrive while that refresh runs return 202 immediately:

    { "accepted": true, "refreshed": false, "coalesced": true }
  3. When the running refresh finishes, Upserve runs exactly one trailing refresh if any event arrived after it started. Its result reflects the newest release state, and the first event's response waits for it.

However many events arrive, a burst costs at most one running and one trailing refresh. A refresh that a client request started before the event isn't reused, because it may predate the publication.

When you pass background (for example executionCtx.waitUntil on Workers), the first event returns 202 with "scheduled": true straight away and the refresh continues in that task. Without background, the first event's response waits for the refresh. GitHub stops waiting after ten seconds, but the refresh still finishes in long-lived servers such as Node.js and Bun.

Cooldowns and failures

Webhook refreshes use the same concurrency pool and respect the same upstream cooldowns as every other refresh. If GitHub is rate limiting, or the refresh fails, the event is still accepted and doesn't contact GitHub again during the cooldown:

{ "accepted": true, "refreshed": false, "deferred": true, "error": "rate_limit" }

The release state change isn't discarded. Each authenticated event first marks the cached release list as due, which is persisted in the cache store. Clients keep receiving the cached data within its stale window. The first update check after the cooldown reloads the release list and provider pages, in this process or any other instance that shares the store, including after a restart. Upserve schedules no timer for this; it reloads on that next request.

Coalescing state is per process. Separate instances that each receive deliveries refresh independently; route webhooks to one instance if you want a single upstream refresh per burst.

What a webhook refreshes

The event forces release-list and provider-page revalidation while respecting upstream cooldowns. It doesn't purge every cached adapter manifest. Publish immutable artifacts in new releases instead of replacing a manifest in place.

Webhook access uses its signature, not your application's authorize() callback. Don't add an open refresh route for clients. For trusted scheduled work in an embedded server, use updates.refresh("editor") directly.

On this page