Publishing on approval
An approved listing gets a page only after the site rebuilds. providers.rebuild picks what asks
for that build; providers.rebuildAuto whether approving asks by itself.
Match your deploy route.
-
Cloudflare → Workers & Pages → your Worker → Settings → Build → Deploy hooks → Create deploy hook, on a repository already connected to Workers Builds.
-
Store the URL.
Terminal pnpm cf:secrets DEPLOY_HOOK_URLThe value comes from
.env.prod; the summary ends withset now: DEPLOY_HOOK_URL. -
Switch the provider on, run
pnpm check:config, push.site.config.ts providers: { rebuild: 'deploy-hook', rebuildAuto: true },
-
deploy.ymllistens forrepository_dispatchof typerebuildand stays skipped until this variable exists; without it, approving publishes nothing.Terminal gh variable set USE_GITHUB_DEPLOY --body true -
A fine-grained token with Contents: Read and write on the building repository (it begins
github_pat_), plus the repository asowner/repo.Terminal pnpm cf:secrets GITHUB_TOKEN GITHUB_REPO -
Switch the provider on and deploy. GitHub fires
repository_dispatchonly on the default branch.site.config.ts providers: { rebuild: 'github-dispatch', rebuildAuto: true },
The default: requests are recorded skipped and you publish yourself.
pnpm deployVerify
Section titled “Verify”Approve one listing in /admin/; the submitter’s page then says “goes live with the next
publish”, the mail “within a few minutes”.
| What to check | Where | You should see |
|---|---|---|
| The request | the /admin/ publishing bar |
Last request: requested via deploy-hook on <date> — build_uuid <id>, or repository_dispatch "rebuild" accepted by <owner/repo> |
| The row | pnpm exec wrangler d1 execute DB --remote --command "SELECT provider, status, detail FROM rebuild_requests ORDER BY created_at DESC LIMIT 1" |
requested, or coalesced when a build was in flight |
| The build | Workers & Pages → Builds, or the Actions run | [zerodirs-d1] D1 (remote): … in its log |
| The page | curl -sI https://<your domain>/<listingBase>/<slug>/ | head -1 |
HTTP/2 200 once the build finishes |
Worth knowing
Section titled “Worth knowing”- A builder needs all three D1 credentials. With a partial set the build fails naming the rest;
with none it has no local database to fall back to and stops on
listings loader: the local database has no listings table. Either way the previous deploy stays live — no build goes green with the page a 404. - Approving asks for a build (
approve:<id>); so do editing, featuring or unfeaturing, the hourlyexpireFeaturedjob (featured-expired) and Publish now (manual). Rejecting never does. - The hourly
retryRebuildsjob refires the oldestfailedrow with fewer than five attempts:429,5xx, timeouts and transport errors count as retryable;404, other4xx, GitHub401/403/422do not — but a row is rescanned until its attempts run out either way. After five, only Publish now orpnpm deploymoves it. rebuildAuto: falseholds every request for Publish now, which fires one build.
When it is off or degraded
Section titled “When it is off or degraded”| State | Visitor sees | /admin/ reports |
Fix |
|---|---|---|---|
rebuild: 'none' |
listings stay off the site | warning; rows skipped |
pnpm deploy, or a provider |
'deploy-hook' without DEPLOY_HOOK_URL |
the same | error: “Approvals will not trigger a build.” | pnpm cf:secrets DEPLOY_HOOK_URL |
'github-dispatch' missing a secret |
the same | error: falls back to none |
pnpm cf:secrets GITHUB_TOKEN GITHUB_REPO |
USE_GITHUB_DEPLOY unset |
dispatch accepted, run skipped | requested, no build |
gh variable set USE_GITHUB_DEPLOY --body true |
| The hook was deleted | nothing builds | failed — HTTP 404: the deploy hook no longer exists |
create a new hook, store it |
| a D1 credential missing on the builder | the previous deploy | requested, build failed: … is set but D1_READ_TOKEN is not set |
add it |
| no D1 credentials on the builder | the previous deploy | requested, build failed: the local database has no listings table |
add all three |
Configuration
Section titled “Configuration”providers.rebuild and providers.rebuildAuto — providers. 'deploy-hook' POSTs DEPLOY_HOOK_URL, 'github-dispatch' posts to GITHUB_REPO with GITHUB_TOKEN, and 'none' records the request and skips it.
Directorysrc/
Directoryserver/
Directoryrebuild/
- index.ts
requestRebuild(), the coalescing window, the row - deploy-hook.ts
- github-dispatch.ts
- none.ts
- index.ts
- jobs.ts
retryRebuilds - queries.ts the approve, update and feature queries
- components/admin/RebuildBar.astro
- loaders/index.ts which database the build reads
- .github/workflows/deploy.yml the
rebuildlistener - .env.example the dashboard path, the token instructions