Deploy the search Worker only after the site it reads from is live

The Worker answers /api/search against search-corpus.json, which the GitHub Pages build produces. Cloudflare was deploying it on its own git trigger, in parallel with that build, so on any given push the Worker could go live pointing at the previous corpus until Pages caught up.

It now deploys from a job in the Pages workflow gated on the deploy step rather than the build step, since the corpus has to be published and not merely built before the Worker can read it.

This needs two things done outside the repo, both noted in the Worker README: add CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as repository secrets, and disconnect the Worker from this repository under Settings > Builds in the Cloudflare dashboard. Until that second step is done both deploy paths fire and the ordering buys nothing.
This commit is contained in:
Classic298 committed 2026-08-08 21:06:31 +02:00
1 parent d5f169ff81
commit 249c8acd9f
2 files changed
+38 -11

No files matched your search

+24
View File
@@ -54,3 +54,27 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Search Worker. Runs last because it answers against search-corpus.json,
# which only exists once the Pages deploy above has published it.
deploy-worker:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: "workers/docs-search/.node-version"
cache: npm
cache-dependency-path: workers/docs-search/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: workers/docs-search
- name: Deploy Worker
run: npx wrangler@4 deploy --config wrangler.toml
working-directory: workers/docs-search
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+14 -11
View File
@@ -5,16 +5,19 @@ This Worker serves `https://docs.openwebui.com/api/search?q=...`.
Do not route `/search*` to this Worker. Docusaurus uses `/search-doc-*.json`
for the built-in search index.
Deploy it from the Cloudflare dashboard using Workers Builds:
The Worker is deployed by the `deploy-worker` job in
`.github/workflows/gh-pages.yml`, which runs only after the GitHub Pages deploy
has finished. That ordering matters: the Worker answers against
`https://docs.openwebui.com/search-corpus.json`, which the Pages build produces,
so deploying the Worker first would point it at the previous corpus.
1. Create or open the `open-webui-docs-search` Worker.
2. Connect this GitHub repository under **Settings > Builds**.
3. Set the Worker root directory to `workers/docs-search`.
4. Use the production branch `main`.
5. Leave the build command empty, or use `echo ready` if Cloudflare requires one.
6. Use `npx wrangler@4 deploy --config wrangler.toml` as the deploy command.
7. Save and deploy.
Two repository secrets are required:
No GitHub Cloudflare secrets are needed. The Worker fetches the static corpus
from `https://docs.openwebui.com/search-corpus.json`, which is generated by the
normal GitHub Pages docs build.
- `CLOUDFLARE_API_TOKEN`, scoped to edit Workers on the `openwebui.com` account
- `CLOUDFLARE_ACCOUNT_ID`
**Turn off Cloudflare's own build trigger.** If the Worker is also connected to
this repository under **Settings > Builds** in the Cloudflare dashboard,
Cloudflare starts its own deploy on every push to `main`, independently of
GitHub Actions and with no ordering against the Pages build. Disconnect that
integration, or the two deploy paths race and the ordering above buys nothing.