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
57 changes: 43 additions & 14 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy Pages
name: Build and deploy website

on:
push:
Expand All @@ -7,8 +7,6 @@ on:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages-${{ github.ref }}
Expand Down Expand Up @@ -54,6 +52,9 @@ jobs:
- name: Validate email routing
run: npm run test:email-worker && npm run check:email-worker

- name: Validate website Worker configuration
run: npm run check:website-worker

- name: Collect active HTML pages
id: active_pages
run: |
Expand Down Expand Up @@ -89,27 +90,55 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v4
- name: Upload website artifact
uses: actions/upload-artifact@v4
with:
name: website
path: ./_site
retention-days: 30
if-no-files-found: error

deploy:
# Publish validated main updates; pull requests only build and check.
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
concurrency:
group: pages-production
group: website-production
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
name: website-production
url: https://www.gecode.dev/
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Checkout
uses: actions/checkout@v7

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm

- name: Install Node dependencies
run: npm ci

- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: website
path: ./_site

- name: Deploy to Cloudflare Workers static assets
run: npx wrangler deploy --env production --config workers/website/wrangler.jsonc
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

- name: Check production availability
run: |
for attempt in 1 2 3 4 5 6; do
if node scripts/check-availability.mjs; then exit 0; fi
if [ "$attempt" -eq 6 ]; then exit 1; fi
echo "Waiting for the deployment to propagate (attempt $attempt)."
sleep 20
done
19 changes: 19 additions & 0 deletions .github/workflows/workers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ on:
- documentation
- redirects
- email
- website

permissions:
contents: read
Expand Down Expand Up @@ -67,6 +68,12 @@ jobs:
echo "canary operations require the documentation worker" >&2
exit 2

- name: Validate website environment
if: inputs.worker == 'website' && inputs.environment == 'canary'
run: |
echo "the website has staging and production environments only" >&2
exit 2

- name: Validate email environment
if: inputs.worker == 'email' && inputs.environment != 'production'
run: |
Expand Down Expand Up @@ -97,6 +104,18 @@ jobs:
if: inputs.worker == 'email'
run: npm run test:email-worker && npm run check:email-worker

- name: Build website
if: inputs.worker == 'website'
run: npm run build:pages && npm run check:website-worker

- name: Deploy website to staging
if: inputs.operation == 'deploy' && inputs.environment == 'staging' && inputs.worker == 'website'
run: npx wrangler deploy --env="" --config workers/website/wrangler.jsonc

- name: Deploy website to production
if: inputs.operation == 'deploy' && inputs.environment == 'production' && inputs.worker == 'website'
run: npx wrangler deploy --env production --config workers/website/wrangler.jsonc

- name: Deploy documentation Worker to staging
if: inputs.operation == 'deploy' && inputs.environment == 'staging' && (inputs.worker == 'both' || inputs.worker == 'documentation')
run: npx wrangler deploy --env="" --config workers/docs/wrangler.jsonc
Expand Down
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</picture>
</p>

# Gecode Website (Astro + GitHub Pages)
# Gecode Website (Astro + Cloudflare Workers)

This repository hosts the Gecode website and is built with Astro and Tailwind
CSS 4. React is available for future interactive islands, but the current site
Expand Down Expand Up @@ -52,8 +52,8 @@ This command:
- checks content transformations, metadata, and canonical URLs
- validates the documentation and redirect Workers

For the GitHub Pages artifact, including the mailing-list archive but excluding
documentation now served from R2, run:
For the deployed website, including the mailing-list archive but excluding
documentation served from R2, run:

```bash
npm run build:pages
Expand All @@ -65,8 +65,14 @@ The legacy rollback/comparison build still copies both frozen archives:
npm run build:deploy
```

That legacy artifact exceeds GitHub Pages' 1 GB published-site limit and must
not be used by the production workflow.
That legacy artifact must not be used by the production workflow.

## Deployment

Pushes to `main` build the site and deploy `_site` to the `gecode-website`
Cloudflare Worker (static assets) on `www.gecode.dev`. See
[Website hosting and TLS](docs/operations.md#website-hosting-and-tls) for the
setup, rollback and monitoring.

## Notes on Scope

Expand Down
4 changes: 4 additions & 0 deletions _headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Workers Static Assets response headers.
# Astro fingerprints these files, so their content never changes.
/_astro/*
Cache-Control: public, max-age=31536000, immutable
27 changes: 16 additions & 11 deletions docs/deployment-runbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ The tested R2 Worker now serves generated documentation in production. The
Astro artifact pairs a redirect Worker for classic active `.html` URLs with
small Pages fallback files.

As checked on 5 September 2026, Cloudflare is authoritative for `gecode.dev`.
Cloudflare proxies the apex GitHub Pages A records and the `www` CNAME to
`gecode.github.io` with Full (strict) TLS and Always Use HTTPS. GitHub Pages
serves the Astro active website and mail archive. All nine historical
Cloudflare is authoritative for `gecode.dev`. Since 16 November 2026 the
website is served by the `gecode-website` Worker (static assets only) on the
`www.gecode.dev` Custom Domain, and a Cloudflare redirect rule sends the apex to
`www`. GitHub Pages no longer serves any part of the site. All nine historical
documentation versions and both latest aliases use R2. Classic active-site
URLs redirect to their canonical directory URLs through the redirect Worker.
URLs redirect to their canonical directory URLs through the redirect Worker and
the website's `_redirects` file. See [Website hosting and
TLS](operations.md#website-hosting-and-tls) for the setup, deployment and
rollback.

Cloudflare Email Routing is ready. Its managed MX, SPF, and DKIM records are
authoritative, both forwarding destinations are verified, and the catch-all
Expand Down Expand Up @@ -303,11 +306,9 @@ old URLs when that Worker is unavailable.
8. Watch Pages, Worker, and R2 errors and documentation 404s during the first
day.

After the Astro deployment is stable, restore automatic Pages deployment for
default-branch pushes in a separate reviewed change.

GitHub Pages receives an artifact comfortably below its 1 GB published-site
limit because generated documentation is no longer copied into it.
Pushes to `main` now deploy the website automatically to the `gecode-website`
Worker. The phase descriptions above refer to the GitHub Pages hosting used
until November 2026.

## 7. Complete release automation

Expand Down Expand Up @@ -366,7 +367,7 @@ Monitor these signals during the first day and review them monthly afterward:
- documentation 404 and 503 responses;
- cache hit ratio and R2 Class A/Class B operations;
- R2 Standard storage, including the size of `staging/`;
- GitHub Pages origin availability; and
- website Worker deployments and edge certificate expiry; and
- Cloudflare Email Routing delivery failures.

Keep a release manifest and a recoverable source for every immutable version.
Expand All @@ -376,6 +377,10 @@ bucket-wide deletion.

## Rollback

The website rolls back to an earlier Worker version; see [Website hosting and
TLS](operations.md#website-hosting-and-tls). The paragraphs below describe the
migration-era Pages rollback and are kept for history.

During the first canary, remove the canary route to return that version to the
existing GitHub Pages archive. Before the Astro cutover, remove the production
documentation routes for the same rollback. If Astro itself must be rolled
Expand Down
88 changes: 86 additions & 2 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and caps each response read at 1 MB. It never downloads the complete PDF.

Transient failures get two retries, twenty seconds apart. Persistent failures
fail the workflow and leave the failing path in its log. Check the failed path,
the latest Pages and Worker deployments, and Cloudflare Workers logs. A version
the latest website and Worker deployments, and Cloudflare Workers logs. A version
or revision mismatch can mean the checked-in promotion has not reached
production yet. Use the deployment runbook for rollback; this workflow never
changes traffic automatically.
Expand Down Expand Up @@ -59,6 +59,84 @@ every failure generated by the documentation Worker or R2. A Workers
Observability notification also needs an actual alert rule; the notification
destination alone does not monitor errors.

## Website hosting and TLS

Since November 2026 the website no longer uses GitHub Pages. Cloudflare serves
everything under `gecode.dev`, and no origin certificate is involved:

- `www.gecode.dev` is a Workers Custom Domain on `gecode-website`, a Worker
with static assets only (no script) built from `_site`. Its configuration is
`workers/website/wrangler.jsonc`.
- More specific Worker routes on `www` take precedence over the Custom Domain:
`gecode-documentation` owns `/doc*` and `/robots.txt*`, and
`gecode-classic-url-redirects` owns the classic `.html` URLs and `/e/*`.
When they pass a request on with `fetch()`, it reaches the website Worker.
- `_site/_redirects` (generated by `scripts/create-classic-redirects.mjs`)
sends `/page` and `/page.html` to `/page/` with a 308. `_headers` marks the
fingerprinted `/_astro/*` files as immutable.
- The apex `gecode.dev` has a proxied placeholder record (`AAAA 100::`) and a
Single Redirect rule. The rule sends HTTP and HTTPS requests to
`https://www.gecode.dev/<path>` with a 301 and keeps the query string.
- Cloudflare Universal SSL issues and renews the edge certificates. The zone
should use **Full (strict)**; it has no external origin.

Static asset requests are free and unlimited on Workers Free, so the website
does not count against the daily Worker request limit unless a route Worker
runs first. A version may hold at most 20,000 files; the build has about
12,200, mostly the users archive.

### Deployment

A push to `main` runs `.github/workflows/pages.yml` ("Build and deploy
website"). It builds and checks the site, uploads the `_site` artifact, then
runs `wrangler deploy --env production` in the `website-production`
environment and finishes with `scripts/check-availability.mjs`. The
environment accepts only `main` and holds two secrets:

- `CLOUDFLARE_ACCOUNT_ID`;
- `CLOUDFLARE_API_TOKEN`: the account token `gecode-website-deploy`, created on
16 November 2026 without expiry. It has Workers Scripts Write and Account
Settings Read on the Gecode account, and Zone Read and Workers Routes Write
on `gecode.dev`. It cannot change DNS, SSL or rules.

The same build can be deployed by hand from the Workers workflow
(`worker=website`) to `www-staging.gecode.dev` or, with the
`cloudflare-production` approval, to production.

### Rollback

Every deploy creates a new Worker version. Roll back without rebuilding:

```sh
npx wrangler deployments list --name gecode-website
npx wrangler rollback --name gecode-website <version-id>
```

Alternatively, rerun an earlier successful "Build and deploy website" run, or
in the dashboard choose Workers & Pages, `gecode-website`, Deployments.
Wrangler needs a token for the Gecode account; local OAuth login may only
cover a personal account.

### Monitoring

The availability check fetches `/news/` with a unique query string, so each
run reaches the deployed assets. It checks the apex redirect, and fails when
either edge certificate has fewer than 14 days left. Universal SSL normally
renews 30 days before expiry, so a failure means renewal is stuck.

### Incident, November 2026

GitHub Pages issued the original origin certificate in August 2026, before
Cloudflare proxied the domain. Pages cannot renew a certificate for a proxied
domain, because its eligibility check requires the records to resolve to
GitHub. The renewal stalled at `bad_authz`, and the certificate expired on
7 November. Cloudflare in Full (strict) mode then returned HTTP 526 for every
uncached page. Toggling the records to DNS only and re-adding the custom domain
did not clear the order. On 12 November the SSL mode was lowered to Full as a
stopgap. On 16 November the website moved to Workers Static Assets, the apex
moved to a Cloudflare redirect rule, and the GitHub Pages A records were
deleted.

## CDN cache policy

The Cloudflare zone's Browser Cache TTL is set to **Respect Existing Headers**.
Expand All @@ -71,6 +149,12 @@ Two active Cache Rules refine that default:
origin cache headers, and uses Cloudflare's status-code TTL when the origin
sends no cache header.

Both rules were written for the GitHub Pages origin. Responses from the website
Worker's static assets do not go through the zone cache, so the Cache Rules no
longer affect them. Static assets
have their own edge caching, and `_headers` sets the browser policy. The two
rules can be removed once nothing depends on them.

Keep `/doc*` out of the website rule. The documentation Worker owns its cache
policy. The prepared Workers Cache change gives selected routes and aliases
thirty days of edge freshness plus seven days of stale-while-revalidate, while
Expand All @@ -97,7 +181,7 @@ separately from billable requests and zone cache hits.
An external CDN can avoid Cloudflare requests on cache hits. A concrete option
is Fastly Full Site Delivery at `www.gecode.dev`, with documentation misses sent
to a dedicated Cloudflare Worker origin hostname and website misses sent to
GitHub Pages. This is a researched option, not a provisioned or tested service.
the website Worker. This is a researched option, not a provisioned or tested service.

Use Fastly's [Surrogate-Control header](https://www.fastly.com/documentation/reference/http/http-headers/Surrogate-Control/)
for the long edge TTL and SWR policy; Cloudflare's edge-only header does not
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"check:docs-hosting": "npm run test:docs-tools && npm run test:docs-worker && npm run check:docs-worker",
"check:docs-worker": "wrangler deploy --dry-run --env canary --config workers/docs/wrangler.jsonc --outdir .wrangler/docs-canary-dry-run && wrangler deploy --dry-run --env production --config workers/docs/wrangler.jsonc --outdir .wrangler/docs-dry-run",
"check:email-worker": "wrangler deploy --dry-run --config workers/email/wrangler.jsonc --outdir .wrangler/email-dry-run",
"check:redirect-worker": "wrangler deploy --dry-run --env production --config workers/redirects/wrangler.jsonc --outdir .wrangler/redirects-dry-run",
"check:website-worker": "wrangler deploy --dry-run --env production --config workers/website/wrangler.jsonc --outdir .wrangler/website-dry-run",
"check:redirect-worker": "wrangler deploy --dry-run --env production --config workers/redirects/wrangler.jsonc --outdir .wrangler/redirects-dry-run",
"check:mode": "./scripts/check-executable-bits.sh",
"check:quality": "npm run build && npm run check:mode && npm run check:html && npm run check:canonical-urls && npm run check:site-semantics && npm run test:content && npm run check:docs-hosting && npm run test:redirect-worker && npm run check:redirect-worker && npm run test:email-worker && npm run check:email-worker",
"dev": "node ./scripts/dev.mjs",
Expand Down
Loading
Loading