Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ resources

# macOS
.DS_Store

# Wrangler state from a deploy run on the Mac
.wrangler
16 changes: 9 additions & 7 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -41,19 +43,19 @@ 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 = [
"scripts/deploy-guard.sh --allow-ahead",
"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"
30 changes: 15 additions & 15 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Agent Notes

<!-- cspell:ignore birdsnearme -- the domain and Cloudflare Pages project name -->

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.

Expand All @@ -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?
```
Expand All @@ -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://<branch>-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.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions scripts/pages-status.sh → scripts/build-status.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,21 +12,21 @@ 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)"'
}

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

Expand All @@ -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
2 changes: 1 addition & 1 deletion scripts/deploy-guard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
17 changes: 17 additions & 0 deletions wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -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": {},
}
Loading