From 34283959a2faf01239b1183a7e20146447e29b77 Mon Sep 17 00:00:00 2001 From: lucasrodes Date: Tue, 19 May 2026 14:39:38 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=A8=F0=9F=A4=96=20Add=20Cloudflare?= =?UTF-8?q?=20Pages=20docs=20deploy=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parallel to ReadTheDocs and GitHub Pages. Builds with zensical and uploads via wrangler to a new owid-docs CF Pages project. Mirrors the same pattern owid/etl is using for its docs subproject. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/deploy-docs-cf.yml | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/deploy-docs-cf.yml diff --git a/.github/workflows/deploy-docs-cf.yml b/.github/workflows/deploy-docs-cf.yml new file mode 100644 index 0000000..421705a --- /dev/null +++ b/.github/workflows/deploy-docs-cf.yml @@ -0,0 +1,49 @@ +name: Deploy docs to Cloudflare Pages + +on: + push: + branches: [main, master] + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +concurrency: + group: deploy-docs-cf-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + enable-cache: true + + - name: Install dependencies + run: uv sync + + - name: Override site_url for the Cloudflare build + run: | + sed -i 's|^site_url = .*|site_url = "https://owid-docs.pages.dev/"|' zensical.toml + + - name: Build docs + run: uv run zensical build --clean + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: >- + pages deploy site + --project-name=owid-docs + --branch=${{ github.head_ref || github.ref_name }} From a648afffeff6abbb40762feaa58e39f989cce0e3 Mon Sep 17 00:00:00 2001 From: lucasrodes Date: Tue, 19 May 2026 14:53:45 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A8=F0=9F=A4=96=20Add=20=5Fworker.?= =?UTF-8?q?js=20to=20proxy=20/projects/etl/=20to=20owid-etl-docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Routes incoming requests on the umbrella custom domain so /projects/etl/* is served from the owid-etl-docs Pages project while everything else falls through to this project's own static assets. Lets one custom domain serve docs from both repos transparently. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/deploy-docs-cf.yml | 3 +++ _worker.js | 32 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 _worker.js diff --git a/.github/workflows/deploy-docs-cf.yml b/.github/workflows/deploy-docs-cf.yml index 421705a..05ce2be 100644 --- a/.github/workflows/deploy-docs-cf.yml +++ b/.github/workflows/deploy-docs-cf.yml @@ -38,6 +38,9 @@ jobs: - name: Build docs run: uv run zensical build --clean + - name: Add _worker.js (path router for subprojects) + run: cp _worker.js site/_worker.js + - name: Deploy to Cloudflare Pages uses: cloudflare/wrangler-action@v3 with: diff --git a/_worker.js b/_worker.js new file mode 100644 index 0000000..f74b9be --- /dev/null +++ b/_worker.js @@ -0,0 +1,32 @@ +// Cloudflare Pages Functions worker for the owid-docs project. +// +// When present at the deployment root, this file intercepts ALL requests +// for this Pages project. We use it as a thin router so that one custom +// domain (docs-cf.owid.io and later docs.owid.io) can transparently serve +// docs from multiple source repos: +// +// /projects/etl/* → proxied to https://owid-etl-docs.pages.dev/projects/etl/* +// everything else → served from this project's own static assets +// +// Each subproject keeps its own GitHub repo, its own CI, and its own +// Pages project (per-PR previews on *.pages.dev still work as today). +// Add a new route here whenever another subproject migrates to CF Pages. + +const SUBPROJECTS = { + "/projects/etl/": "https://owid-etl-docs.pages.dev", +}; + +export default { + async fetch(request, env) { + const url = new URL(request.url); + + for (const [prefix, origin] of Object.entries(SUBPROJECTS)) { + if (url.pathname.startsWith(prefix)) { + const target = `${origin}${url.pathname}${url.search}`; + return fetch(target, request); + } + } + + return env.ASSETS.fetch(request); + }, +};