Skip to content

Commit 249c8ac

Browse files
committed
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.
1 parent d5f169f commit 249c8ac

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

.github/workflows/gh-pages.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,27 @@ jobs:
5454
- name: Deploy to GitHub Pages
5555
id: deployment
5656
uses: actions/deploy-pages@v4
57+
58+
# Search Worker. Runs last because it answers against search-corpus.json,
59+
# which only exists once the Pages deploy above has published it.
60+
deploy-worker:
61+
runs-on: ubuntu-latest
62+
needs: deploy
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
- name: Setup Node
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version-file: "workers/docs-search/.node-version"
70+
cache: npm
71+
cache-dependency-path: workers/docs-search/package-lock.json
72+
- name: Install dependencies
73+
run: npm ci
74+
working-directory: workers/docs-search
75+
- name: Deploy Worker
76+
run: npx wrangler@4 deploy --config wrangler.toml
77+
working-directory: workers/docs-search
78+
env:
79+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
80+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

workers/docs-search/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ This Worker serves `https://docs.openwebui.com/api/search?q=...`.
55
Do not route `/search*` to this Worker. Docusaurus uses `/search-doc-*.json`
66
for the built-in search index.
77

8-
Deploy it from the Cloudflare dashboard using Workers Builds:
8+
The Worker is deployed by the `deploy-worker` job in
9+
`.github/workflows/gh-pages.yml`, which runs only after the GitHub Pages deploy
10+
has finished. That ordering matters: the Worker answers against
11+
`https://docs.openwebui.com/search-corpus.json`, which the Pages build produces,
12+
so deploying the Worker first would point it at the previous corpus.
913

10-
1. Create or open the `open-webui-docs-search` Worker.
11-
2. Connect this GitHub repository under **Settings > Builds**.
12-
3. Set the Worker root directory to `workers/docs-search`.
13-
4. Use the production branch `main`.
14-
5. Leave the build command empty, or use `echo ready` if Cloudflare requires one.
15-
6. Use `npx wrangler@4 deploy --config wrangler.toml` as the deploy command.
16-
7. Save and deploy.
14+
Two repository secrets are required:
1715

18-
No GitHub Cloudflare secrets are needed. The Worker fetches the static corpus
19-
from `https://docs.openwebui.com/search-corpus.json`, which is generated by the
20-
normal GitHub Pages docs build.
16+
- `CLOUDFLARE_API_TOKEN`, scoped to edit Workers on the `openwebui.com` account
17+
- `CLOUDFLARE_ACCOUNT_ID`
18+
19+
**Turn off Cloudflare's own build trigger.** If the Worker is also connected to
20+
this repository under **Settings > Builds** in the Cloudflare dashboard,
21+
Cloudflare starts its own deploy on every push to `main`, independently of
22+
GitHub Actions and with no ordering against the Pages build. Disconnect that
23+
integration, or the two deploy paths race and the ordering above buys nothing.

0 commit comments

Comments
 (0)