From de531528c01d57e22441d19b4e5d5a001faa480b Mon Sep 17 00:00:00 2001 From: Gerry Shaw Date: Sun, 25 Oct 2026 09:15:46 -0700 Subject: [PATCH] Serve birdsnearme.com from a Worker, built by Workers Builds Co-Authored-By: Claude Opus 5.5 --- .gitignore | 3 ++ .mise.toml | 16 ++++++----- AGENTS.md | 30 ++++++++++---------- README.md | 4 +-- cspell.config.yaml | 1 + scripts/{pages-status.sh => build-status.sh} | 18 ++++++------ scripts/deploy-guard.sh | 2 +- wrangler.jsonc | 17 +++++++++++ 8 files changed, 57 insertions(+), 34 deletions(-) rename scripts/{pages-status.sh => build-status.sh} (56%) create mode 100644 wrangler.jsonc diff --git a/.gitignore b/.gitignore index bfd09cb..bdcd231 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ resources # macOS .DS_Store + +# Wrangler state from a deploy run on the Mac +.wrangler diff --git a/.mise.toml b/.mise.toml index 333efdc..1061e88 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,11 +1,13 @@ [tools] -# Cloudflare Pages reads HUGO_VERSION from the project's settings: change both -# together. See AGENTS.md. +# Workers Builds reads HUGO_VERSION from the Worker's two build triggers: change +# all three together. See AGENTS.md. hugo = "0.167.0" node = "24.4.1" "npm:cspell" = "9.1.5" "npm:markdownlint-cli2" = "0.22.1" lychee = "0.24.2" +# Workers Builds deploys with this version too (npx wrangler@…). +"npm:wrangler" = "4.143.1" [tasks.dev] run = "hugo server --port 4002 --openBrowser" @@ -31,7 +33,7 @@ run = "lychee --offline --no-progress --fallback-extensions html --root-dir \"$P [tasks.check] depends = ["spell", "markdownlint", "links"] -# Run by deploy once Cloudflare Pages has built main. +# Run by deploy once Workers Builds has deployed main. [tasks.verify] run = """ set -e @@ -41,8 +43,8 @@ test "$(curl -s -o /dev/null -w '%{http_code}' https://birdsnearme.com/no-such-p echo "404 page works" """ -# The one way to production. See Workshop's Tooling/deploy.md. Cloudflare Pages -# builds main on push, so the push is the deploy and main may be ahead of origin. +# The one way to production. See Workshop's Tooling/deploy.md. Workers Builds +# builds and deploys main on push, so the push is the deploy and main may be ahead of origin. # The guard runs again after check in case check changed a file. [tasks.deploy] run = [ @@ -50,10 +52,10 @@ run = [ "mise run check", "scripts/deploy-guard.sh --allow-ahead", "git push origin main", - "scripts/pages-status.sh --wait", + "scripts/build-status.sh --wait", "mise run verify", 'echo "✅ $(git rev-parse --short HEAD) is live on birdsnearme.com and verified."', ] [tasks.deploy-status] -run = "scripts/pages-status.sh" +run = "scripts/build-status.sh" diff --git a/AGENTS.md b/AGENTS.md index f0286e0..5909cb6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,14 +1,12 @@ # Agent Notes - - Background for AI agents working in this repo. ## What this is The marketing site for Birds Near Me, a worldwide birding field guide for iPhone built on -eBird data, live at [birdsnearme.com](https://birdsnearme.com). A Hugo site on Cloudflare -Pages. The app itself lives in a separate repo, `BirdsNearMe`. +eBird data, live at [birdsnearme.com](https://birdsnearme.com). A Hugo site served by a Cloudflare Worker (`birdsnearme-website`) that has no script, only +the built files. The app itself lives in a separate repo, `BirdsNearMe`. **The repo and the site are both public.** Anything committed here is published. @@ -20,7 +18,7 @@ template is in `layouts/`. ```sh mise run dev # hugo server on :4002 with live reload mise run check # build + spell + markdownlint + internal links -mise run deploy # guard, check, push, wait for Pages, verify +mise run deploy # guard, check, push, wait for the build, verify mise run verify # curl the live site mise run deploy-status # is main live? ``` @@ -30,19 +28,21 @@ prints `Files checked: N`. A green run over zero files checked nothing. ## Deploys -Cloudflare Pages project `birdsnearme-website` builds every push. `main` goes to -production; other branches get a preview URL. The build runs -`hugo --cleanDestinationDir --panicOnWarning` into `public/`, with `HUGO_VERSION` set in the -Cloudflare project for production and preview, so a Hugo bump means changing `.mise.toml` -and that variable together. `--panicOnWarning` makes a deprecation fail the build rather -than scroll past. +Workers Builds builds every push. `main` runs `hugo` and `wrangler deploy` to +production; any other branch runs `wrangler preview`, which gives it a Preview URL +(`https://-birdsnearme-website.gerry-shaw.workers.dev`) and a comment on its PR. +`wrangler.jsonc` serves `public/` with no script. The build runs +`hugo --cleanDestinationDir --panicOnWarning`, and the two build triggers each set +`HUGO_VERSION`, so a Hugo bump means changing `.mise.toml` and both triggers together. +`--panicOnWarning` makes a deprecation fail the build rather than scroll past. **Deploy with `mise run deploy`**, never a bare `git push` to `main`. `scripts/deploy-guard.sh` refuses unless the branch is `main`, the tree is clean and -`origin/main` isn't ahead. Then it runs `check`, pushes, waits for the "Cloudflare Pages" -check run on the commit (`scripts/pages-status.sh --wait`) and runs `verify`. A merged PR -also deploys, since Pages builds every push to `main`. The rule and the list of sites are -in [Workshop's deploy note](https://github.com/gshaw/Workshop/blob/main/Tooling/deploy.md). +`origin/main` isn't ahead. Then it runs `check`, pushes, waits for the "Workers Builds: +birdsnearme-website" check run on the commit (`scripts/build-status.sh --wait`) and runs +`verify`. A merged PR also deploys, since Workers Builds deploys every push to `main`. The +rule and the list of sites are in +[Workshop's deploy note](https://github.com/gshaw/Workshop/blob/main/Tooling/deploy.md). GitHub Actions runs `mise run -c check` on pushes and PRs. It doesn't block Cloudflare. diff --git a/README.md b/README.md index 8d56ccd..23c4a28 100755 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ mise run dev # http://localhost:4002 with live reload mise run check # build, spell check, markdown lint, internal links ``` -Deploy with `mise run deploy`. It refuses unless you're on a clean `main` with nothing newer on GitHub, then checks, pushes, waits for Cloudflare Pages and runs `mise run verify`. `mise run deploy-status` says whether `main` is live. The rule is in [Workshop's deploy note](https://github.com/gshaw/Workshop/blob/main/Tooling/deploy.md). +Deploy with `mise run deploy`. It refuses unless you're on a clean `main` with nothing newer on GitHub, then checks, pushes, waits for Workers Builds and runs `mise run verify`. `mise run deploy-status` says whether `main` is live. The rule is in [Workshop's deploy note](https://github.com/gshaw/Workshop/blob/main/Tooling/deploy.md). ## Powered By - Domain Registrar: [Cloudflare Registrar](https://www.cloudflare.com/products/registrar/) - DNS: [Cloudflare DNS](https://www.cloudflare.com/dns/) -- Hosting: [Cloudflare Pages](https://pages.cloudflare.com) +- Hosting: [Cloudflare Workers](https://workers.cloudflare.com), static assets, built by Workers Builds - Build System: [Hugo](https://gohugo.io) - CSS: [Pico.css](https://picocss.com) diff --git a/cspell.config.yaml b/cspell.config.yaml index 8ade9e2..9dcbafc 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -9,6 +9,7 @@ ignorePaths: - "resources" - "pico.min.css" words: + - birdsnearme # the domain and the Worker's name - gshaw - ogimage # front matter key for the Open Graph image - pico diff --git a/scripts/pages-status.sh b/scripts/build-status.sh similarity index 56% rename from scripts/pages-status.sh rename to scripts/build-status.sh index 17b64b6..d650dea 100755 --- a/scripts/pages-status.sh +++ b/scripts/build-status.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -# Says whether main is live, from the "Cloudflare Pages" check run that Pages -# puts on each commit it builds. See Workshop's Tooling/deploy.md. +# Says whether main is live, from the "Workers Builds: birdsnearme-website" check run that +# Workers Builds puts on each commit it builds and deploys. See Workshop's Tooling/deploy.md. # -# scripts/pages-status.sh # mise run deploy-status -# scripts/pages-status.sh --wait # after a push: wait until origin/main is live +# scripts/build-status.sh # mise run deploy-status +# scripts/build-status.sh --wait # after a push: wait until origin/main is live set -euo pipefail git fetch --quiet origin main @@ -12,9 +12,9 @@ sha=$(git rev-parse origin/main) short=${sha:0:7} # "completed success", "completed failure", "in_progress null", or nothing -# before Pages has seen the commit. +# before Workers Builds has seen the commit. build() { - gh api "repos/$repo/commits/$sha/check-runs?check_name=Cloudflare%20Pages" \ + gh api "repos/$repo/commits/$sha/check-runs?check_name=Workers%20Builds%3A%20birdsnearme-website" \ --jq '.check_runs[0] // empty | "\(.status) \(.conclusion)"' } @@ -22,11 +22,11 @@ if [[ ${1:-} == --wait ]]; then for _ in $(seq 60); do case $(build) in "completed success") echo "$short is live." && exit 0 ;; - completed*) echo "Cloudflare Pages failed to build $short." >&2 && exit 1 ;; + completed*) echo "Workers Builds failed to build $short." >&2 && exit 1 ;; esac sleep 10 done - echo "Cloudflare Pages hasn't finished $short after 10 minutes." >&2 + echo "Workers Builds hasn't finished $short after 10 minutes." >&2 exit 1 fi @@ -35,6 +35,6 @@ ahead=$(git rev-list --count origin/main..main) case $(build) in "completed success") echo "origin/main ($short) is live." ;; completed*) echo "origin/main ($short) failed to build. An older commit is live." ;; - "") echo "Cloudflare Pages hasn't built origin/main ($short)." ;; + "") echo "Workers Builds hasn't built origin/main ($short)." ;; *) echo "origin/main ($short) is building." ;; esac diff --git a/scripts/deploy-guard.sh b/scripts/deploy-guard.sh index a10dd4c..7b42eb8 100755 --- a/scripts/deploy-guard.sh +++ b/scripts/deploy-guard.sh @@ -4,7 +4,7 @@ # of sites are in Workshop's Tooling/deploy.md. # # scripts/deploy-guard.sh # a Worker: main must equal origin/main -# scripts/deploy-guard.sh --allow-ahead # Cloudflare Pages: the push is the deploy +# scripts/deploy-guard.sh --allow-ahead # Workers Builds: the push is the deploy set -euo pipefail refuse() { diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 0000000..435153e --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,17 @@ +// birdsnearme.com is static: Workers Builds runs `hugo` on every push and this Worker +// serves public/, with no script of its own. Branches get a Preview. +{ + "$schema": "https://unpkg.com/wrangler@4.143.1/config-schema.json", + "name": "birdsnearme-website", + "compatibility_date": "2026-10-25", + "assets": { + "directory": "./public", + "not_found_handling": "404-page", + }, + "routes": [{ "pattern": "birdsnearme.com", "custom_domain": true }], + // Production only at birdsnearme.com; a branch's Preview gets a workers.dev URL, + // which Cloudflare marks for search engines not to index. + "workers_dev": false, + "preview_urls": true, + "previews": {}, +}