From 747d6fa4e55bb1f372d5bd375369004ad6086819 Mon Sep 17 00:00:00 2001 From: Tern Date: Thu, 12 Nov 2026 09:05:57 -0500 Subject: [PATCH 1/6] deploy: a Workers preview per PR, production on merge, workflows locked down The dev environment O.J. set on 12 November. Every PR from this repo gets its own Workers Preview at a stable URL, posted as a comment, deleted on close. A merge to main re-runs the fast checks on the merge commit and deploys production. GitHub Pages keeps serving the domain until she cuts DNS over. The site moves from a Pages config to a Worker with static assets. The Worker runs first only under /api/*, and .assetsignore keeps the docs, tools and configs out of the upload. GitHub Pages was serving CLAUDE.md and wrangler.toml to anyone who asked. The workflows deny every permission at the top and grant per job, checkouts drop their credentials, every action is pinned in actions.lock and kept current by Dependabot, zizmor and actionlint run on every PR, and a new job fails any PR that changes agents/ without a regenerate title. Scorecard publishes weekly. Merge method is merge commits, her call the same day. CLAUDE.md and AGENTS.md say so. Agent-Session: https://claude.ai/code/session_01YWyGCmBWG4ubvKVLmq9QvM Model: claude-fable-5-1 --- .assetsignore | 20 ++++ .coderabbit.yaml | 7 +- .github/dependabot.yml | 17 +++ .github/workflows/actions.lock | 87 ++++++++++++++++ .github/workflows/checks.yaml | 105 +++++++++++++++++-- .github/workflows/ci.yaml | 37 ++++--- .github/workflows/deploy.yaml | 172 +++++++++++++++++++++++++++++++ .github/workflows/scorecard.yaml | 41 ++++++++ AGENTS.md | 10 +- CHANGELOG.md | 7 ++ CLAUDE.md | 13 ++- README.md | 8 +- SECURITY.md | 15 +-- functions/api/health.js | 14 +-- functions/worker.js | 32 ++++++ index.html | 4 +- lychee.toml | 4 + resources.html | 2 +- showcase.html | 2 +- wrangler.toml | 40 +++++-- 20 files changed, 573 insertions(+), 64 deletions(-) create mode 100644 .assetsignore create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/actions.lock create mode 100644 .github/workflows/deploy.yaml create mode 100644 .github/workflows/scorecard.yaml create mode 100644 functions/worker.js diff --git a/.assetsignore b/.assetsignore new file mode 100644 index 0000000..e945310 --- /dev/null +++ b/.assetsignore @@ -0,0 +1,20 @@ +# What stays out of the static asset upload. The repo root is the site, so without this +# list the working agreement, the checks and the review config would be served to anyone +# who asked for them, which GitHub Pages was doing until 12 November 2026. +.git +.github +.githooks +.claude +.wrangler +.DS_Store +.gitignore +.coderabbit.yaml +.assetsignore +*.md +CNAME +docs +functions +tools +lychee.toml +lighthouserc.json +wrangler.toml diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 60197a8..a715ed5 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -75,7 +75,7 @@ reviews: has a prefers-reduced-motion branch. - path: "functions/**" instructions: >- - Cloudflare Pages Functions. Secrets come from env bindings, never code. Validate every + The Cloudflare Worker and its routes. Secrets come from env bindings, never code. Validate every input, verify Stripe webhook signatures, return no-store on dynamic responses, never log request bodies. No npm dependencies, the Workers runtime APIs only. - path: "tools/**" @@ -86,8 +86,9 @@ reviews: blocklist, because this repository is public. - path: ".github/workflows/**" instructions: >- - Least privilege on permissions, actions pinned to a major version tag, no secrets - echoed. checks.yaml must stay equivalent to what tools/check runs locally. + Deny-all permissions at the top with per-job grants, persist-credentials off on every + checkout, every action in actions.lock, no secrets echoed. checks.yaml must stay + equivalent to what tools/check runs locally. - path: "{CHANGELOG.md,CLAUDE.md,AGENTS.md,README.md}" instructions: >- Prose follows CLAUDE.md Brand voice. No em dashes. A new page needs a row in the diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6ee5442 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +# Keeps the workflow actions current. Each PR it opens updates the tag in the workflow and +# the matching commit in actions.lock together. There is nothing else to update: the site +# has no package manager by design. +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + day: monday + time: "07:00" + timezone: America/New_York + groups: + actions: + patterns: ["*"] + commit-message: + prefix: "ci" diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 0000000..7276453 --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,87 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/checks.yaml': + - 'actions/checkout@v7.0.1' + - 'lycheeverse/lychee-action@v2.9.0' + - 'treosh/lighthouse-ci-action@12.6.2' + - 'zizmorcore/zizmor-action@v0.8.1' + '.github/workflows/ci.yaml': + - 'actions/checkout@v7.0.1' + - 'actions/configure-pages@v6.0.0' + - 'actions/deploy-pages@v5.0.1' + - 'actions/upload-pages-artifact@v5.0.0' + '.github/workflows/deploy.yaml': + - 'actions/checkout@v7.0.1' + - 'cloudflare/wrangler-action@v4.1.3' + '.github/workflows/scorecard.yaml': + - 'actions/checkout@v7.0.1' + - 'github/codeql-action@v4.39.3' + - 'ossf/scorecard-action@v2.5.0' +dependencies: + 'actions/checkout@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' + owner_id: 44036562 + repo_id: 197814629 + 'actions/configure-pages@v6.0.0': + ref: 'v6.0.0' + commit: 'sha1-45bfe0192ca1faeb007ade9deae92b16b8254a0d' + owner_id: 44036562 + repo_id: 513659658 + 'actions/deploy-pages@v5.0.1': + ref: 'v5.0.1' + commit: 'sha1-368f82528645a54fb793d4d04e342629a3f51346' + owner_id: 44036562 + repo_id: 438112499 + 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f': + ref: 'v7.0.0' + commit: 'sha1-bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' + owner_id: 44036562 + repo_id: 192625955 + 'actions/upload-pages-artifact@v5.0.0': + ref: 'v5.0.0' + commit: 'sha1-fc324d3547104276b827a68afc52ff2a11cc49c9' + owner_id: 44036562 + repo_id: 496012378 + uses: + - 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' + 'cloudflare/wrangler-action@v4.1.3': + ref: 'v4.1.3' + commit: 'sha1-953926a2e2182532811c01a25e53647d93bf07c0' + owner_id: 314135 + repo_id: 213471363 + 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370': + ref: 'v4.39.1' + commit: 'sha1-9b3254085494b55a0f7c4c2b3d2d52cc712ce370' + owner_id: 9919 + repo_id: 259445878 + 'github/codeql-action@v4.39.3': + ref: 'v4.39.3' + commit: 'sha1-33d7b85da1a04171e211befe2c739303b9a4c066' + owner_id: 9919 + repo_id: 259445878 + 'lycheeverse/lychee-action@v2.9.0': + ref: 'v2.9.0' + commit: 'sha1-e7477775783ea5526144ba13e8db5eec57747ce8' + owner_id: 74027027 + repo_id: 320929718 + 'ossf/scorecard-action@v2.5.0': + ref: 'v2.5.0' + commit: 'sha1-fa7117db83c52d787ae5a89f350999701505d78e' + owner_id: 67707773 + repo_id: 421101922 + 'treosh/lighthouse-ci-action@12.6.2': + ref: '12.6.2' + commit: 'sha1-3e7e23fb74242897f95c0ba9cabad3d0227b9b18' + owner_id: 30832600 + repo_id: 210552904 + 'zizmorcore/zizmor-action@v0.8.1': + ref: 'v0.8.1' + commit: 'sha1-45d7276c9ca790aabd705e31ca99c6185c3e76dd' + owner_id: 210636713 + repo_id: 985558803 + uses: + - 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370' diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 6d101ab..c15a44c 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -1,22 +1,40 @@ +# The checks every PR has to pass before O.J. merges it. The same four jobs tools/check runs +# locally, plus the two that only make sense on GitHub: the workflow linters, and the gate +# that keeps hand edits out of the generated agents/ pages. +# +# Job names are referenced by the ruleset on main as required checks. Rename one here and +# the ruleset has to change with it, so the four tools/check names stay as they are. +# +# Actions are referenced by tag for readability. The exact commits that run are recorded in +# actions.lock beside this file (gh actions-lock), and Dependabot updates both together. + name: Checks on: pull_request: workflow_dispatch: -permissions: - contents: read +# Deny everything at the top. Each job grants only what it reads. +permissions: {} + +# A newer push to the same PR cancels the run in progress. +concurrency: + group: checks-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: last-updated: name: Living pages carry the date git says runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout with history - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.1 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false - name: Check the dates run: python3 tools/last-reviewed/check.py @@ -24,15 +42,18 @@ jobs: local-checks: name: Names, HTML validity (the same run as tools/check) runs-on: ubuntu-latest + permissions: + contents: read steps: # tools/check runs the living-pages date check too, and that reads dates from git, so # this job needs the same full history as the job above. A shallow checkout dates # every file to the merge commit, which only passes on the day a page last changed. - name: Checkout with history - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.1 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false - name: Install HTML Tidy run: sudo apt-get update -q && sudo apt-get install -y -q tidy @@ -43,11 +64,15 @@ jobs: links: name: Internal links resolve runs-on: ubuntu-latest + permissions: + contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false - name: lychee, offline - uses: lycheeverse/lychee-action@v2 + uses: lycheeverse/lychee-action@v2.9.0 with: args: --offline --no-progress --config lychee.toml --root-dir ${{ github.workspace }} '*.html' 'agents/**/*.html' fail: true @@ -55,12 +80,76 @@ jobs: lighthouse: name: Lighthouse on the main pages runs-on: ubuntu-latest + permissions: + contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false - name: Lighthouse CI - uses: treosh/lighthouse-ci-action@v12 + uses: treosh/lighthouse-ci-action@12.6.2 with: configPath: lighthouserc.json uploadArtifacts: true temporaryPublicStorage: true + + workflows: + name: Workflows are pinned, linted and least-privilege + runs-on: ubuntu-latest + permissions: + contents: read + # zizmor uploads its findings as SARIF so they show under Security, Code scanning. + security-events: write + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + # The lockfile has to match the workflows. --no-fix writes nothing and exits 1 when a + # workflow references an action the lockfile does not pin. + - name: The lockfile covers every action + run: gh actions-lock --no-fix + env: + GH_TOKEN: ${{ github.token }} + + - name: actionlint, workflow syntax and expression mistakes + run: docker run --rm -v "${PWD}:/repo" --workdir /repo rhysd/actionlint:1.7.12 -color + + - name: zizmor, workflow security + uses: zizmorcore/zizmor-action@v0.8.1 + with: + min-severity: low + + generated: + name: Generated pages only change in a regeneration + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + # agents/** is built from the internal repo by its publisher and never edited here by + # hand. A regeneration PR announces itself in the title, so anything else touching those + # files is a hand edit and fails. Same rule CodeRabbit's custom check describes, enforced + # where it cannot be skipped. + - name: Hand edits under agents/ fail + env: + TITLE: ${{ github.event.pull_request.title }} + BASE: ${{ github.event.pull_request.base.sha }} + HEAD: ${{ github.event.pull_request.head.sha }} + run: | + if [ -z "$BASE" ]; then echo "not a pull request, nothing to compare"; exit 0; fi + changed=$(git diff --name-only "$BASE...$HEAD" -- agents/ || true) + if [ -z "$changed" ]; then echo "agents/ untouched"; exit 0; fi + case "$TITLE" in + "regenerate /agents"*) echo "regeneration PR, agents/ changes allowed"; exit 0 ;; + esac + echo "This PR changes generated pages without a 'regenerate /agents' title:" + printf '%s\n' "$changed" | sed 's/^/ /' + echo + echo "Change the source in the internal repo and regenerate with the publisher." + exit 1 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b36ce48..e37f211 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,18 +1,18 @@ +# GitHub Pages, the hosting learnwithoj.com still points at. It stays until O.J. cuts DNS +# over to the Worker that deploy.yaml publishes, then this file goes. Until that day both +# deploy on every merge, and the one the domain points at is what visitors see. + name: Deploy to GitHub Pages on: push: - branches: - - main # or 'master' if that's your default branch + branches: [main] workflow_dispatch: -permissions: - contents: read - pages: write - id-token: write +permissions: {} concurrency: - group: "pages" + group: pages cancel-in-progress: false jobs: @@ -21,19 +21,24 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write steps: - name: Checkout - uses: actions/checkout@v4 - + uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Setup Pages - uses: actions/configure-pages@v4 - + uses: actions/configure-pages@v6.0.0 + - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v5.0.0 with: - path: '.' - + path: "." + - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 - + uses: actions/deploy-pages@v5.0.1 diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..46bd270 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,172 @@ +# Cloudflare Workers: a preview for every pull request, production on every merge to main. +# +# The flow O.J. set on 12 November 2026. A PR is a complete thing. It carries its preview +# URL, she and Codex comment on the preview, the author iterates on the branch, she merges, +# and main deploys to production. Nothing reaches production without a merge, and a merge +# needs the Checks workflow green under the ruleset on main. +# +# Previews are Workers Previews, one per PR, named pr-, isolated from production. +# The URL is stable across pushes, so the link in the PR description stays right. The +# preview is deleted when the PR closes. +# +# The two secrets, CLOUDFLARE_API_TOKEN (Workers Scripts Edit) and CLOUDFLARE_ACCOUNT_ID, +# are repository secrets O.J. sets. Repository secrets are not available to a PR from a +# fork, and the preview job also refuses to run on one, so a fork cannot spend them. +# +# The GitHub Pages workflow (ci.yaml) keeps serving learnwithoj.com until she cuts DNS over +# to the Worker. Until then this workflow deploys to the workers.dev hostname only. + +name: Deploy + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + push: + branches: [main] + workflow_dispatch: + +permissions: {} + +concurrency: + group: deploy-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + WRANGLER_VERSION: "4.160.1" + +jobs: + preview: + name: Preview for the pull request + if: >- + github.event_name == 'pull_request' && + github.event.action != 'closed' && + github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + # Until O.J. adds the two secrets this job has nothing to deploy with. It says so and + # stops green rather than failing every PR in the meantime. + - name: The Cloudflare secrets exist + id: gate + env: + TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + ACCOUNT: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + run: | + if [ -n "$TOKEN" ] && [ -n "$ACCOUNT" ]; then + echo "ready=true" >> "$GITHUB_OUTPUT" + else + echo "::notice::CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are not set, skipping" + echo "ready=false" >> "$GITHUB_OUTPUT" + fi + + - name: Upload the preview + id: preview + if: steps.gate.outputs.ready == 'true' + uses: cloudflare/wrangler-action@v4.1.3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + wranglerVersion: ${{ env.WRANGLER_VERSION }} + command: preview --name "pr-${{ github.event.pull_request.number }}" --var "COMMIT_SHA:${{ github.event.pull_request.head.sha }}" --var "BRANCH:${{ github.head_ref }}" + + # One comment per PR, edited on every push, so the thread stays short for her. + - name: Post the preview URL on the PR + if: steps.gate.outputs.ready == 'true' + env: + GH_TOKEN: ${{ github.token }} + PR: ${{ github.event.pull_request.number }} + URL: ${{ steps.preview.outputs.preview-url }} + SHA: ${{ github.event.pull_request.head.sha }} + run: | + gh pr comment "$PR" --edit-last --create-if-none --body "Preview: $URL (commit ${SHA:0:7})" + + cleanup: + name: Delete the preview when the PR closes + if: >- + github.event_name == 'pull_request' && + github.event.action == 'closed' && + github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + # Until O.J. adds the two secrets this job has nothing to deploy with. It says so and + # stops green rather than failing every PR in the meantime. + - name: The Cloudflare secrets exist + id: gate + env: + TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + ACCOUNT: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + run: | + if [ -n "$TOKEN" ] && [ -n "$ACCOUNT" ]; then + echo "ready=true" >> "$GITHUB_OUTPUT" + else + echo "::notice::CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are not set, skipping" + echo "ready=false" >> "$GITHUB_OUTPUT" + fi + + - if: steps.gate.outputs.ready == 'true' + uses: cloudflare/wrangler-action@v4.1.3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + wranglerVersion: ${{ env.WRANGLER_VERSION }} + command: preview delete --name "pr-${{ github.event.pull_request.number }}" --skip-confirmation + + production: + name: Deploy main to production + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + environment: + name: production + url: ${{ steps.deploy.outputs.deployment-url }} + permissions: + contents: read + steps: + - uses: actions/checkout@v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + # Until O.J. adds the two secrets this job has nothing to deploy with. It says so and + # stops green rather than failing every PR in the meantime. + - name: The Cloudflare secrets exist + id: gate + env: + TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + ACCOUNT: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + run: | + if [ -n "$TOKEN" ] && [ -n "$ACCOUNT" ]; then + echo "ready=true" >> "$GITHUB_OUTPUT" + else + echo "::notice::CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are not set, skipping" + echo "ready=false" >> "$GITHUB_OUTPUT" + fi + + # The same fast checks the PR passed, run once more on the merge commit itself, so a + # merge that combined two green PRs into one broken tree stops here. + - name: Install HTML Tidy + run: sudo apt-get update -q && sudo apt-get install -y -q tidy + + - name: The checks pass on the merge commit + run: python3 tools/check --no-links + + - name: Deploy + id: deploy + if: steps.gate.outputs.ready == 'true' + uses: cloudflare/wrangler-action@v4.1.3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + wranglerVersion: ${{ env.WRANGLER_VERSION }} + command: deploy --var "COMMIT_SHA:${{ github.sha }}" --var "BRANCH:main" diff --git a/.github/workflows/scorecard.yaml b/.github/workflows/scorecard.yaml new file mode 100644 index 0000000..c01463e --- /dev/null +++ b/.github/workflows/scorecard.yaml @@ -0,0 +1,41 @@ +# OpenSSF Scorecard, the public supply-chain report card for this repo. Runs on main after +# every push and weekly, uploads to the Scorecard API for the README badge, and files its +# findings under Security, Code scanning. Reads the ruleset on main with the default token. + +name: Scorecard + +on: + push: + branches: [main] + schedule: + - cron: "17 6 * * 1" + workflow_dispatch: + +permissions: {} + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + # Needed to publish results and get a badge. + id-token: write + + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + - name: Run analysis + uses: ossf/scorecard-action@v2.5.0 + with: + results_file: results.sarif + results_format: sarif + publish_results: true + + - name: Upload to code scanning + uses: github/codeql-action/upload-sarif@v4.39.3 + with: + sarif_file: results.sarif diff --git a/AGENTS.md b/AGENTS.md index 7c7a6f0..f6c34bc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,15 +23,16 @@ Vercel, not "good enough". - `styles.css`, the only stylesheet, tokens at the top - `agents/**`, generated from the internal repo and never edited by hand here - `SECURITY.md`, private reporting instructions and the website's security review context -- `functions/`, Cloudflare Pages Functions (`/api/health` today, Stripe webhook and signed downloads later) +- `functions/`, the Worker and its `/api/*` routes (`/api/health` today, Stripe webhook and signed downloads later) +- `.assetsignore`, what stays out of the asset upload, so the docs and tools above never reach the site - `tools/`, the checks (`tools/check`, `tools/last-reviewed`, `tools/policy-pii`) -- `.github/workflows/`, `ci.yaml` deploys, `checks.yaml` runs the checks on every PR +- `.github/workflows/`, `checks.yaml` runs the checks on every PR, `deploy.yaml` gives every PR a Workers Preview and deploys `main` to production, `ci.yaml` is GitHub Pages until DNS moves, `actions.lock` pins every action to a commit ## How to run ``` python3 -m http.server 8000 # static preview -wrangler pages dev . # preview with the Functions runtime +wrangler dev # preview with the Workers runtime ``` ## Checks, and what done means @@ -53,7 +54,8 @@ page touched, `CHANGELOG.md` has an entry, a new page has a row in the pages tab - Commit as yourself, `git commit --author="Name "`. O.J. stays the committer. New commits use `Agent-Session:` and `Model:` trailers. Historical `Claude-Session:` trailers stay intact, and session-recovery tools should recognize both. -- Branch per change, PR body signed with your name, `oj-codes` assigned. She merges by rebase. +- Branch per change, PR body signed with your name, `oj-codes` assigned, the preview URL from the + Deploy workflow's comment copied into the description. She merges with a merge commit. - Human review is the final merge decision. Wait for O.J.'s explicit approval comment on that PR. Green checks, a clean bot review or another PR's approval do not authorize a merge. Surface substantive changes after approval and obtain renewed approval for them. diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d8c1b..58f0129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,15 @@ The format is inspired by [Keep a Changelog](https://keepachangelog.com), and th ## [Unreleased] ### Added +- Cloudflare Workers hosting. `functions/worker.js` serves the static site and runs first under `/api/*`, `.assetsignore` keeps the docs, tools and configs off the site (GitHub Pages served `CLAUDE.md` and `wrangler.toml` to anyone who asked), and `/api/health` reports the deployed commit +- A Deploy workflow. Every pull request from this repo gets its own Workers Preview at a stable URL, posted as a comment on the PR and deleted when it closes. A merge to `main` re-runs the fast checks on the merge commit and deploys production. GitHub Pages keeps serving the domain until DNS moves +- The Checks workflow gains two jobs. One lints the workflows (actionlint, zizmor) and verifies `actions.lock`. One fails any PR that changes `agents/` unless its title starts with `regenerate /agents` +- `actions.lock` pins every action to a commit (GitHub workflow lockfiles, GA 28 October 2026), Dependabot updates the actions weekly, and an OpenSSF Scorecard workflow publishes the badge in the README - `SECURITY.md` with private vulnerability reporting, current site boundaries and security review guidance ### Changed +- Workflows deny every permission at the top and grant per job, checkouts don't persist credentials, and the actions move to their current majors (checkout v7, Pages actions v5 and v6) +- PRs merge with a merge commit rather than a rebase, O.J.'s call 12 November 2026. `CLAUDE.md` and `AGENTS.md` say so +- Links to `/resources.html` become `/resources`, because the Worker serves clean paths and redirects the `.html` form - `AGENTS.md` clarifies generated updates, decorative image alt text, approved purchase integrations and the evidence expected in reviews and PR descriptions - New commits use `Agent-Session` for attribution across harnesses, and agents surface mismatched labels before writing durable records - Merge approval requires O.J.'s explicit comment on the particular PR after human review diff --git a/CLAUDE.md b/CLAUDE.md index 50af3db..6efca9c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -51,7 +51,8 @@ The site itself is the proof of capability. Every visitor is making a snap judgm ## Tech stack - Plain HTML, CSS, vanilla JS. No framework, no build step, no bundler. -- Hosted on GitHub Pages. `CNAME` points to `learnwithoj.com`. The move to Cloudflare Pages is in progress: `wrangler.toml` and `functions/` are in place and `wrangler pages dev .` previews the site with the Functions runtime, and the DNS cutover happens once O.J. has connected the repo in the Cloudflare dashboard and approved the preview. +- Hosted on Cloudflare Workers with static assets. `wrangler.toml` is the Worker config, `functions/worker.js` is the Worker, and `.assetsignore` keeps the repo's internals off the site. `wrangler dev` previews the site with the Workers runtime. GitHub Pages (`ci.yaml`, `CNAME`) keeps serving learnwithoj.com until O.J. cuts DNS over to the Worker, then both go. +- Dev environment, since 12 November 2026. Every PR gets its own Workers Preview at a stable URL, posted as a comment on the PR by the Deploy workflow. A PR is a complete thing. Put the preview link in the description, O.J. and Codex comment on the preview, iterate on the branch, she merges, and main deploys to production. - Deploys via `.github/workflows/ci.yaml` on push to `main`. - Stripe Checkout for paid B2C services (links live in `index.html` `#pricing`). Not used on B2B pages. - Kit (ConvertKit) for the email-gated AI guide. Form UID: `36c7f50077`. @@ -67,8 +68,10 @@ functional-emotions.html The Desperation Dial explainer, first of a series. Sp tools/check One command for every local check, the same ones the Checks workflow runs. Run it before pushing tools/last-reviewed/ Derives the "Last updated" date on living pages from git, run by the Checks workflow on PRs tools/policy-pii/ PII and name gate over the generated agents/ pages. Allowlist only, copied from the internal repo. No blocklist here, this repo is public -functions/ Cloudflare Pages Functions. /api/health today, the Stripe webhook and signed downloads later -wrangler.toml Cloudflare Pages configuration, output directory is the repo root +functions/ The Worker (worker.js) and its routes under functions/api/. /api/health today, the Stripe webhook and signed downloads later +wrangler.toml Cloudflare Workers configuration, the repo root is the assets directory +.assetsignore What stays out of the asset upload: the docs, the tools, the configs +.github/workflows/ checks.yaml on every PR, deploy.yaml for previews and production, ci.yaml for GitHub Pages until cutover, scorecard.yaml weekly. actions.lock pins every action to a commit AGENTS.md Code review rules for Codex and CodeRabbit. Points at this file, adds nothing to it .githooks/ pre-commit runs tools/check on staged files. Enable with git config core.hooksPath .githooks lychee.toml Link checker config. lighthouserc.json is the Lighthouse CI config. .coderabbit.yaml is CodeRabbit's @@ -208,8 +211,8 @@ These are real and have been validated. Use as needed. - The 1% for the Planet footer block is a compliance surface. Primary logo only, at least 80px tall, linked, next to the business name, with their precertification wording. The wording is theirs and any rewrite needs O.J.'s sign-off against the live guidelines. Never the Certified Business seal, never the Impact Partner mark, no dollar figure, no "certified". The rules are filed in the internal repo under `content/branding`. - Run the oj-voice linter on every page before shipping copy. It lives in the internal repo, not here, and gets invoked from there. `tools/check --voice` does that when the internal repo sits beside this one as `../the-grove`. - Run `tools/check` before pushing, and enable the pre-commit hook once per clone with `git config core.hooksPath .githooks`. CI runs the same checks, so a green local run is a green PR. -- Agents author their own commits, `git commit --author="Name "`, and O.J. stays the committer. New commits use `Agent-Session:` and `Model:` trailers, no harness attribution lines. Corrected 30 October 2026 at O.J.'s instruction. This previously required `Claude-Session:` regardless of harness, which mislabeled Codex sessions. Historical trailers stay intact and session-recovery tools should recognize both names. PRs merge by rebase so per-commit authorship survives on `main`. Policy since 19 October 2026; the eight October squash commits before it were rewritten the same day, see `docs/commit-map-20261019.md` once it lands. -- For local preview: `python3 -m http.server 8000`, or `wrangler pages dev .` when a Pages Function is involved. The Kit form won't fully work locally (needs Kit's JS to load against the live form), but it should render. +- Agents author their own commits, `git commit --author="Name "`, and O.J. stays the committer. New commits use `Agent-Session:` and `Model:` trailers, no harness attribution lines. Corrected 30 October 2026 at O.J.'s instruction. This previously required `Claude-Session:` regardless of harness, which mislabeled Codex sessions. Historical trailers stay intact and session-recovery tools should recognize both names. PRs merge with a merge commit, her call 12 November 2026, because the full branch history is what agents read and verify against. Rebase was the policy from 19 October to 12 November; the eight October squash commits before that were rewritten the same day, see `docs/commit-map-20261019.md`. +- For local preview: `python3 -m http.server 8000`, or `wrangler dev` when the Worker is involved. The Kit form won't fully work locally (needs Kit's JS to load against the live form), but it should render. ## Performance and accessibility expectations diff --git a/README.md b/README.md index ad1c89c..2db011f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ Career strategy and 1:1 technical sessions for software and infrastructure engin ## Overview -A static site for [learnwithoj.com](https://learnwithoj.com) offering career strategy, resume review, and hands-on technical sessions for experienced software and infrastructure engineers. Built with plain HTML, CSS, and JavaScript, deployed to GitHub Pages. +A static site for [learnwithoj.com](https://learnwithoj.com) offering career strategy, resume review, and hands-on technical sessions for experienced software and infrastructure engineers. Built with plain HTML, CSS, and JavaScript, deployed to Cloudflare Workers. + +[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/oj-codes/learnwithoj.com/badge)](https://scorecard.dev/viewer/?uri=github.com/oj-codes/learnwithoj.com) ## Tech Stack @@ -15,7 +17,7 @@ A static site for [learnwithoj.com](https://learnwithoj.com) offering career str - Stripe Checkout for payments - Kit (ConvertKit) for email capture - GoatCounter for privacy-friendly analytics -- GitHub Pages for hosting +- Cloudflare Workers for hosting, with a Preview per pull request ## Project Structure @@ -42,4 +44,4 @@ Then open `http://localhost:8000` in your browser. ## Deployment -Pushes to `main` trigger the GitHub Actions workflow in `.github/workflows/ci.yaml`, which deploys the site to GitHub Pages. The custom domain is configured via the `CNAME` file. +Every pull request gets its own Workers Preview from `.github/workflows/deploy.yaml`, posted as a comment on the PR. A merge to `main` deploys production the same way. `.github/workflows/ci.yaml` still deploys GitHub Pages, which serves the custom domain until DNS moves to the Worker. diff --git a/SECURITY.md b/SECURITY.md index 0e5ca61..2cc84b6 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,12 +12,15 @@ Actions logs. Use a private report for sensitive evidence. ## Scope and current implementation This repository is the public marketing website. It contains plain HTML, one stylesheet, -vanilla JavaScript, generated agent-policy pages, and Cloudflare Pages Functions. - -The GitHub Pages workflow currently publishes the repository root. Cloudflare Pages -configuration is checked in for the hosting move. The implemented Function is -`functions/api/health.js`, which returns a health flag and deployment commit and branch -metadata with `Cache-Control: no-store`. +vanilla JavaScript, generated agent-policy pages, and a Cloudflare Worker. + +The GitHub Pages workflow publishes the repository root and keeps serving the domain until +DNS moves to the Worker. The Workers deploy uploads the root as static assets minus +`.assetsignore`, so the working agreement, the checks and the configs are not served. The +Worker runs first only under `/api/*`. The implemented route is `/api/health`, which returns +a health flag and the deployed commit and branch with `Cache-Control: no-store`. Every pull +request from this repository gets a public Workers Preview on `workers.dev`, sent with +`X-Robots-Tag: noindex`; forks get none, and the Cloudflare token is never exposed to one. Approved Stripe Checkout links and the Kit form are live B2C integrations. Their providers handle the current checkout and email submission flows. This repo does not currently diff --git a/functions/api/health.js b/functions/api/health.js index 83b49dd..cd057b5 100644 --- a/functions/api/health.js +++ b/functions/api/health.js @@ -1,13 +1,13 @@ -// Cloudflare Pages Function, served at /api/health. +// GET /api/health // -// The first server-side route on the site. It answers with the commit and branch that -// Pages deployed, so a watcher can tell which build is live without reading the HTML. -// The Stripe webhook and the signed download handler for the marketplace land beside it. -export function onRequestGet({ env }) { +// The first server-side route on the site. It answers with the commit and branch the +// deploy workflow passed in as vars, so a watcher can tell which build is live without +// reading the HTML. Locally, under wrangler dev, both are null. +export function health(request, env) { const body = { ok: true, - commit: env.CF_PAGES_COMMIT_SHA || null, - branch: env.CF_PAGES_BRANCH || null, + commit: env.COMMIT_SHA || null, + branch: env.BRANCH || null, }; return new Response(JSON.stringify(body), { headers: { diff --git a/functions/worker.js b/functions/worker.js new file mode 100644 index 0000000..052d1ea --- /dev/null +++ b/functions/worker.js @@ -0,0 +1,32 @@ +// The Worker in front of the static site. +// +// Cloudflare serves every request from the uploaded assets first, except the paths listed +// under run_worker_first in wrangler.toml, which arrive here. Today that is /api/*, with one +// route. The Stripe webhook and the signed download handler for the marketplace go in +// functions/api/ beside health.js and get a line in the table below. +// +// Anything this Worker does not recognize falls through to the assets binding, so a miss +// gets the site's 404 page rather than a bare response. + +import { health } from "./api/health.js"; + +const routes = { + "/api/health": health, +}; + +export default { + async fetch(request, env) { + const url = new URL(request.url); + const handler = routes[url.pathname]; + if (handler) { + if (request.method !== "GET" && request.method !== "HEAD") { + return new Response("Method not allowed", { + status: 405, + headers: { allow: "GET, HEAD", "cache-control": "no-store" }, + }); + } + return handler(request, env); + } + return env.ASSETS.fetch(request); + }, +}; diff --git a/index.html b/index.html index 8b539ab..c6cdc0d 100644 --- a/index.html +++ b/index.html @@ -70,7 +70,7 @@ @@ -97,7 +97,7 @@
O.J. introduces Learn with O.J. in about two minutes.
diff --git a/showcase.html b/showcase.html index b77d6be..54ac108 100644 --- a/showcase.html +++ b/showcase.html @@ -61,7 +61,7 @@ diff --git a/wrangler.toml b/wrangler.toml index 9ee264f..45bee42 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,11 +1,35 @@ -# Cloudflare Pages configuration. +# Cloudflare Workers configuration. The site is static assets served by a Worker, with the +# Worker running first only under /api/*. # -# The site is plain HTML with no build step, so the output directory is the repo root, -# the same thing GitHub Pages uploads today. Local preview with the Functions runtime: +# Local preview with the Workers runtime: wrangler dev +# Validate without uploading: wrangler deploy --dry-run --outdir /tmp/lwoj-dry # -# wrangler pages dev . -# -# The project name is what the Cloudflare dashboard shows. Change it there and here together. +# Production deploys from .github/workflows/deploy.yaml on every merge to main, and every +# pull request gets its own Preview (wrangler preview --name pr-N). The custom domain is +# added in the dashboard when O.J. cuts DNS over from GitHub Pages; until then the Worker +# answers on workers.dev only, so nothing here can change where learnwithoj.com points. + name = "learnwithoj-com" -compatibility_date = "2026-10-23" -pages_build_output_dir = "." +main = "functions/worker.js" +compatibility_date = "2026-11-12" + +# workers.dev hostname on, which is also what makes Preview URLs resolve. +workers_dev = true + +[assets] +# The repo root is the site. .assetsignore lists what stays out of the upload. +directory = "." +binding = "ASSETS" +# Everything is served from assets first except these paths, which the Worker owns. +run_worker_first = ["/api/*"] +# /showcase serves showcase.html, and a trailing slash redirects to the clean path. +html_handling = "auto-trailing-slash" +# Serve 404.html with a 404 status once the page exists. Until then a miss is a plain 404. +not_found_handling = "404-page" + +[observability] +enabled = true + +# Previews use the top-level configuration as is. Give a binding its own preview resource +# under this table (for example a separate D1 database) the day production gets one. +[previews] From a7b57696150fb5ea1b4a6e249ffdf61f1bbdf32e Mon Sep 17 00:00:00 2001 From: Tern Date: Thu, 12 Nov 2026 09:09:23 -0500 Subject: [PATCH 2/6] checks: install the lockfile extension on the runner gh actions-lock is a gh extension, not a built-in, so the runner installs it before verifying. Agent-Session: https://claude.ai/code/session_01YWyGCmBWG4ubvKVLmq9QvM Model: claude-fable-5-1 --- .github/workflows/checks.yaml | 4 +++- CHANGELOG.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index c15a44c..9f06230 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -109,7 +109,9 @@ jobs: # The lockfile has to match the workflows. --no-fix writes nothing and exits 1 when a # workflow references an action the lockfile does not pin. - name: The lockfile covers every action - run: gh actions-lock --no-fix + run: | + gh extension install github/gh-actions-lock + gh actions-lock --no-fix env: GH_TOKEN: ${{ github.token }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 58f0129..0066cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ The format is inspired by [Keep a Changelog](https://keepachangelog.com), and th ### Changed - Workflows deny every permission at the top and grant per job, checkouts don't persist credentials, and the actions move to their current majors (checkout v7, Pages actions v5 and v6) - PRs merge with a merge commit rather than a rebase, O.J.'s call 12 November 2026. `CLAUDE.md` and `AGENTS.md` say so -- Links to `/resources.html` become `/resources`, because the Worker serves clean paths and redirects the `.html` form +- Links to `/resources.html` become `/resources` on the three service pages, because the Worker serves clean paths and redirects the `.html` form. The explainer keeps its link so its living date stays true - `AGENTS.md` clarifies generated updates, decorative image alt text, approved purchase integrations and the evidence expected in reviews and PR descriptions - New commits use `Agent-Session` for attribution across harnesses, and agents surface mismatched labels before writing durable records - Merge approval requires O.J.'s explicit comment on the particular PR after human review From aaa9ca7bab5d7d1028627985776a70c6959ad179 Mon Sep 17 00:00:00 2001 From: Tern Date: Thu, 12 Nov 2026 09:11:24 -0500 Subject: [PATCH 3/6] deploy: a manual production run only from main, and a week of cooldown on action updates Codex's P1 on PR 42. workflow_dispatch on a feature branch would have checked out and published that branch as production. The job now requires the ref to be main whatever the event. zizmor's code-scanning finding on the Dependabot config is the cooldown. Agent-Session: https://claude.ai/code/session_01YWyGCmBWG4ubvKVLmq9QvM Model: claude-fable-5-1 --- .github/dependabot.yml | 4 ++++ .github/workflows/deploy.yaml | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6ee5442..90af794 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,6 +10,10 @@ updates: day: monday time: "07:00" timezone: America/New_York + # A new release waits a week before Dependabot proposes it, so a hijacked tag that gets + # yanked in its first days never reaches a PR here. + cooldown: + default-days: 7 groups: actions: patterns: ["*"] diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 46bd270..52087b0 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -125,7 +125,9 @@ jobs: production: name: Deploy main to production - if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + # A manual run is allowed only from main itself. Dispatching the workflow on a feature + # branch would otherwise check out and publish that branch (Codex, PR 42). + if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') runs-on: ubuntu-latest environment: name: production From 514baf18e2062bb66f375c3c27c73fbf07e650d3 Mon Sep 17 00:00:00 2001 From: Tern Date: Thu, 12 Nov 2026 09:48:11 -0500 Subject: [PATCH 4/6] deploy: Workers Builds runs previews and production, no Cloudflare credential in GitHub Codex's security finding on PR 42. A pull_request workflow runs code the branch controls, so a preview job holding a Cloudflare token could be rewritten by any same-repo branch to read it, and Cloudflare has no preview-only scope for a Worker. The Deploy workflow goes. Workers Builds, connected to the repo on Cloudflare's side, deploys main and gives every other branch a Preview, with no token stored here. /api/health reports the serving Worker version from the version_metadata binding, so it works the same from any deploy path. The commit and branch stay optional vars the dashboard deploy command passes in. Agent-Session: https://claude.ai/code/session_01YWyGCmBWG4ubvKVLmq9QvM Model: claude-fable-5-1 --- .coderabbit.yaml | 2 +- .github/workflows/actions.lock | 8 -- .github/workflows/ci.yaml | 2 +- .github/workflows/deploy.yaml | 174 --------------------------------- AGENTS.md | 4 +- CHANGELOG.md | 2 +- CLAUDE.md | 4 +- README.md | 4 +- SECURITY.md | 7 +- functions/api/health.js | 8 +- functions/worker.js | 3 +- wrangler.toml | 22 ++++- 12 files changed, 38 insertions(+), 202 deletions(-) delete mode 100644 .github/workflows/deploy.yaml diff --git a/.coderabbit.yaml b/.coderabbit.yaml index a715ed5..43ef35f 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -75,7 +75,7 @@ reviews: has a prefers-reduced-motion branch. - path: "functions/**" instructions: >- - The Cloudflare Worker and its routes. Secrets come from env bindings, never code. Validate every + The Cloudflare Worker and its routes, deployed by Workers Builds. Secrets come from env bindings, never code. Validate every input, verify Stripe webhook signatures, return no-store on dynamic responses, never log request bodies. No npm dependencies, the Workers runtime APIs only. - path: "tools/**" diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index 7276453..a06214e 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -13,9 +13,6 @@ workflows: - 'actions/configure-pages@v6.0.0' - 'actions/deploy-pages@v5.0.1' - 'actions/upload-pages-artifact@v5.0.0' - '.github/workflows/deploy.yaml': - - 'actions/checkout@v7.0.1' - - 'cloudflare/wrangler-action@v4.1.3' '.github/workflows/scorecard.yaml': - 'actions/checkout@v7.0.1' - 'github/codeql-action@v4.39.3' @@ -48,11 +45,6 @@ dependencies: repo_id: 496012378 uses: - 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' - 'cloudflare/wrangler-action@v4.1.3': - ref: 'v4.1.3' - commit: 'sha1-953926a2e2182532811c01a25e53647d93bf07c0' - owner_id: 314135 - repo_id: 213471363 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370': ref: 'v4.39.1' commit: 'sha1-9b3254085494b55a0f7c4c2b3d2d52cc712ce370' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e37f211..25e50a2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,5 @@ # GitHub Pages, the hosting learnwithoj.com still points at. It stays until O.J. cuts DNS -# over to the Worker that deploy.yaml publishes, then this file goes. Until that day both +# over to the Worker that Workers Builds publishes, then this file goes. Until that day both # deploy on every merge, and the one the domain points at is what visitors see. name: Deploy to GitHub Pages diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml deleted file mode 100644 index 52087b0..0000000 --- a/.github/workflows/deploy.yaml +++ /dev/null @@ -1,174 +0,0 @@ -# Cloudflare Workers: a preview for every pull request, production on every merge to main. -# -# The flow O.J. set on 12 November 2026. A PR is a complete thing. It carries its preview -# URL, she and Codex comment on the preview, the author iterates on the branch, she merges, -# and main deploys to production. Nothing reaches production without a merge, and a merge -# needs the Checks workflow green under the ruleset on main. -# -# Previews are Workers Previews, one per PR, named pr-, isolated from production. -# The URL is stable across pushes, so the link in the PR description stays right. The -# preview is deleted when the PR closes. -# -# The two secrets, CLOUDFLARE_API_TOKEN (Workers Scripts Edit) and CLOUDFLARE_ACCOUNT_ID, -# are repository secrets O.J. sets. Repository secrets are not available to a PR from a -# fork, and the preview job also refuses to run on one, so a fork cannot spend them. -# -# The GitHub Pages workflow (ci.yaml) keeps serving learnwithoj.com until she cuts DNS over -# to the Worker. Until then this workflow deploys to the workers.dev hostname only. - -name: Deploy - -on: - pull_request: - types: [opened, synchronize, reopened, closed] - push: - branches: [main] - workflow_dispatch: - -permissions: {} - -concurrency: - group: deploy-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -env: - WRANGLER_VERSION: "4.160.1" - -jobs: - preview: - name: Preview for the pull request - if: >- - github.event_name == 'pull_request' && - github.event.action != 'closed' && - github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - # Until O.J. adds the two secrets this job has nothing to deploy with. It says so and - # stops green rather than failing every PR in the meantime. - - name: The Cloudflare secrets exist - id: gate - env: - TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - ACCOUNT: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - run: | - if [ -n "$TOKEN" ] && [ -n "$ACCOUNT" ]; then - echo "ready=true" >> "$GITHUB_OUTPUT" - else - echo "::notice::CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are not set, skipping" - echo "ready=false" >> "$GITHUB_OUTPUT" - fi - - - name: Upload the preview - id: preview - if: steps.gate.outputs.ready == 'true' - uses: cloudflare/wrangler-action@v4.1.3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - wranglerVersion: ${{ env.WRANGLER_VERSION }} - command: preview --name "pr-${{ github.event.pull_request.number }}" --var "COMMIT_SHA:${{ github.event.pull_request.head.sha }}" --var "BRANCH:${{ github.head_ref }}" - - # One comment per PR, edited on every push, so the thread stays short for her. - - name: Post the preview URL on the PR - if: steps.gate.outputs.ready == 'true' - env: - GH_TOKEN: ${{ github.token }} - PR: ${{ github.event.pull_request.number }} - URL: ${{ steps.preview.outputs.preview-url }} - SHA: ${{ github.event.pull_request.head.sha }} - run: | - gh pr comment "$PR" --edit-last --create-if-none --body "Preview: $URL (commit ${SHA:0:7})" - - cleanup: - name: Delete the preview when the PR closes - if: >- - github.event_name == 'pull_request' && - github.event.action == 'closed' && - github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - # Until O.J. adds the two secrets this job has nothing to deploy with. It says so and - # stops green rather than failing every PR in the meantime. - - name: The Cloudflare secrets exist - id: gate - env: - TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - ACCOUNT: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - run: | - if [ -n "$TOKEN" ] && [ -n "$ACCOUNT" ]; then - echo "ready=true" >> "$GITHUB_OUTPUT" - else - echo "::notice::CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are not set, skipping" - echo "ready=false" >> "$GITHUB_OUTPUT" - fi - - - if: steps.gate.outputs.ready == 'true' - uses: cloudflare/wrangler-action@v4.1.3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - wranglerVersion: ${{ env.WRANGLER_VERSION }} - command: preview delete --name "pr-${{ github.event.pull_request.number }}" --skip-confirmation - - production: - name: Deploy main to production - # A manual run is allowed only from main itself. Dispatching the workflow on a feature - # branch would otherwise check out and publish that branch (Codex, PR 42). - if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - runs-on: ubuntu-latest - environment: - name: production - url: ${{ steps.deploy.outputs.deployment-url }} - permissions: - contents: read - steps: - - uses: actions/checkout@v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - # Until O.J. adds the two secrets this job has nothing to deploy with. It says so and - # stops green rather than failing every PR in the meantime. - - name: The Cloudflare secrets exist - id: gate - env: - TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - ACCOUNT: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - run: | - if [ -n "$TOKEN" ] && [ -n "$ACCOUNT" ]; then - echo "ready=true" >> "$GITHUB_OUTPUT" - else - echo "::notice::CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are not set, skipping" - echo "ready=false" >> "$GITHUB_OUTPUT" - fi - - # The same fast checks the PR passed, run once more on the merge commit itself, so a - # merge that combined two green PRs into one broken tree stops here. - - name: Install HTML Tidy - run: sudo apt-get update -q && sudo apt-get install -y -q tidy - - - name: The checks pass on the merge commit - run: python3 tools/check --no-links - - - name: Deploy - id: deploy - if: steps.gate.outputs.ready == 'true' - uses: cloudflare/wrangler-action@v4.1.3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - wranglerVersion: ${{ env.WRANGLER_VERSION }} - command: deploy --var "COMMIT_SHA:${{ github.sha }}" --var "BRANCH:main" diff --git a/AGENTS.md b/AGENTS.md index f6c34bc..a48e09d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,7 @@ Vercel, not "good enough". - `functions/`, the Worker and its `/api/*` routes (`/api/health` today, Stripe webhook and signed downloads later) - `.assetsignore`, what stays out of the asset upload, so the docs and tools above never reach the site - `tools/`, the checks (`tools/check`, `tools/last-reviewed`, `tools/policy-pii`) -- `.github/workflows/`, `checks.yaml` runs the checks on every PR, `deploy.yaml` gives every PR a Workers Preview and deploys `main` to production, `ci.yaml` is GitHub Pages until DNS moves, `actions.lock` pins every action to a commit +- `.github/workflows/`, `checks.yaml` runs the checks on every PR, `ci.yaml` is GitHub Pages until DNS moves, `actions.lock` pins every action to a commit. Deploys and previews run through Cloudflare Workers Builds, not here, so no Cloudflare credential is in GitHub ## How to run @@ -55,7 +55,7 @@ page touched, `CHANGELOG.md` has an entry, a new page has a row in the pages tab committer. New commits use `Agent-Session:` and `Model:` trailers. Historical `Claude-Session:` trailers stay intact, and session-recovery tools should recognize both. - Branch per change, PR body signed with your name, `oj-codes` assigned, the preview URL from the - Deploy workflow's comment copied into the description. She merges with a merge commit. + Cloudflare app's comment copied into the description. She merges with a merge commit. - Human review is the final merge decision. Wait for O.J.'s explicit approval comment on that PR. Green checks, a clean bot review or another PR's approval do not authorize a merge. Surface substantive changes after approval and obtain renewed approval for them. diff --git a/CHANGELOG.md b/CHANGELOG.md index 0066cab..ac75461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ The format is inspired by [Keep a Changelog](https://keepachangelog.com), and th ## [Unreleased] ### Added - Cloudflare Workers hosting. `functions/worker.js` serves the static site and runs first under `/api/*`, `.assetsignore` keeps the docs, tools and configs off the site (GitHub Pages served `CLAUDE.md` and `wrangler.toml` to anyone who asked), and `/api/health` reports the deployed commit -- A Deploy workflow. Every pull request from this repo gets its own Workers Preview at a stable URL, posted as a comment on the PR and deleted when it closes. A merge to `main` re-runs the fast checks on the merge commit and deploys production. GitHub Pages keeps serving the domain until DNS moves +- Deploys through Cloudflare Workers Builds. Every branch gets its own Workers Preview at a stable URL, posted on the PR by the Cloudflare app, and a merge to `main` deploys production. No Cloudflare credential lives in GitHub, after Codex's security review of PR #42 showed that a preview job holding a deploy token can be rewritten by any branch that runs it. GitHub Pages keeps serving the domain until DNS moves - The Checks workflow gains two jobs. One lints the workflows (actionlint, zizmor) and verifies `actions.lock`. One fails any PR that changes `agents/` unless its title starts with `regenerate /agents` - `actions.lock` pins every action to a commit (GitHub workflow lockfiles, GA 28 October 2026), Dependabot updates the actions weekly, and an OpenSSF Scorecard workflow publishes the badge in the README - `SECURITY.md` with private vulnerability reporting, current site boundaries and security review guidance diff --git a/CLAUDE.md b/CLAUDE.md index 6efca9c..3386622 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -52,7 +52,7 @@ The site itself is the proof of capability. Every visitor is making a snap judgm - Plain HTML, CSS, vanilla JS. No framework, no build step, no bundler. - Hosted on Cloudflare Workers with static assets. `wrangler.toml` is the Worker config, `functions/worker.js` is the Worker, and `.assetsignore` keeps the repo's internals off the site. `wrangler dev` previews the site with the Workers runtime. GitHub Pages (`ci.yaml`, `CNAME`) keeps serving learnwithoj.com until O.J. cuts DNS over to the Worker, then both go. -- Dev environment, since 12 November 2026. Every PR gets its own Workers Preview at a stable URL, posted as a comment on the PR by the Deploy workflow. A PR is a complete thing. Put the preview link in the description, O.J. and Codex comment on the preview, iterate on the branch, she merges, and main deploys to production. +- Dev environment, since 12 November 2026. Workers Builds is connected to this repo on Cloudflare's side, so a push to main deploys production and every other branch gets its own Workers Preview at a stable URL, posted on the PR by the Cloudflare GitHub app. No Cloudflare credential lives in GitHub. A PR is a complete thing. Put the preview link in the description, O.J. and Codex comment on the preview, iterate on the branch, she merges, and main deploys to production. - Deploys via `.github/workflows/ci.yaml` on push to `main`. - Stripe Checkout for paid B2C services (links live in `index.html` `#pricing`). Not used on B2B pages. - Kit (ConvertKit) for the email-gated AI guide. Form UID: `36c7f50077`. @@ -71,7 +71,7 @@ tools/policy-pii/ PII and name gate over the generated agents/ pages. Allo functions/ The Worker (worker.js) and its routes under functions/api/. /api/health today, the Stripe webhook and signed downloads later wrangler.toml Cloudflare Workers configuration, the repo root is the assets directory .assetsignore What stays out of the asset upload: the docs, the tools, the configs -.github/workflows/ checks.yaml on every PR, deploy.yaml for previews and production, ci.yaml for GitHub Pages until cutover, scorecard.yaml weekly. actions.lock pins every action to a commit +.github/workflows/ checks.yaml on every PR, ci.yaml for GitHub Pages until cutover, scorecard.yaml weekly. actions.lock pins every action to a commit. Deploys are not here, Workers Builds runs them AGENTS.md Code review rules for Codex and CodeRabbit. Points at this file, adds nothing to it .githooks/ pre-commit runs tools/check on staged files. Enable with git config core.hooksPath .githooks lychee.toml Link checker config. lighthouserc.json is the Lighthouse CI config. .coderabbit.yaml is CodeRabbit's diff --git a/README.md b/README.md index 2db011f..2706997 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A static site for [learnwithoj.com](https://learnwithoj.com) offering career str - Stripe Checkout for payments - Kit (ConvertKit) for email capture - GoatCounter for privacy-friendly analytics -- Cloudflare Workers for hosting, with a Preview per pull request +- Cloudflare Workers for hosting, with a Preview per pull request through Workers Builds ## Project Structure @@ -44,4 +44,4 @@ Then open `http://localhost:8000` in your browser. ## Deployment -Every pull request gets its own Workers Preview from `.github/workflows/deploy.yaml`, posted as a comment on the PR. A merge to `main` deploys production the same way. `.github/workflows/ci.yaml` still deploys GitHub Pages, which serves the custom domain until DNS moves to the Worker. +Cloudflare Workers Builds watches the repo. Every pull request branch gets its own Workers Preview, posted as a comment on the PR, and a merge to `main` deploys production. No deploy credential lives in this repo. `.github/workflows/ci.yaml` still deploys GitHub Pages, which serves the custom domain until DNS moves to the Worker. diff --git a/SECURITY.md b/SECURITY.md index 2cc84b6..74bbf03 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -18,9 +18,10 @@ The GitHub Pages workflow publishes the repository root and keeps serving the do DNS moves to the Worker. The Workers deploy uploads the root as static assets minus `.assetsignore`, so the working agreement, the checks and the configs are not served. The Worker runs first only under `/api/*`. The implemented route is `/api/health`, which returns -a health flag and the deployed commit and branch with `Cache-Control: no-store`. Every pull -request from this repository gets a public Workers Preview on `workers.dev`, sent with -`X-Robots-Tag: noindex`; forks get none, and the Cloudflare token is never exposed to one. +a health flag, the serving Worker version and the deployed commit and branch with +`Cache-Control: no-store`. Deploys run through Cloudflare Workers Builds on Cloudflare's side, +so no Cloudflare credential is stored in this repository or available to its workflows. Every +branch gets a public Workers Preview on `workers.dev`, sent with `X-Robots-Tag: noindex`. Approved Stripe Checkout links and the Kit form are live B2C integrations. Their providers handle the current checkout and email submission flows. This repo does not currently diff --git a/functions/api/health.js b/functions/api/health.js index cd057b5..b3cb717 100644 --- a/functions/api/health.js +++ b/functions/api/health.js @@ -1,11 +1,13 @@ // GET /api/health // -// The first server-side route on the site. It answers with the commit and branch the -// deploy workflow passed in as vars, so a watcher can tell which build is live without -// reading the HTML. Locally, under wrangler dev, both are null. +// The first server-side route on the site. It answers with the Worker version that is +// serving, plus the commit and branch when the deploy command passed them in as vars, so +// a watcher can tell which build is live without reading the HTML. Locally, under +// wrangler dev, the commit and branch are null. export function health(request, env) { const body = { ok: true, + version: env.CF_VERSION_METADATA ? env.CF_VERSION_METADATA.id : null, commit: env.COMMIT_SHA || null, branch: env.BRANCH || null, }; diff --git a/functions/worker.js b/functions/worker.js index 052d1ea..4057dc3 100644 --- a/functions/worker.js +++ b/functions/worker.js @@ -6,7 +6,8 @@ // functions/api/ beside health.js and get a line in the table below. // // Anything this Worker does not recognize falls through to the assets binding, so a miss -// gets the site's 404 page rather than a bare response. +// gets the site's 404 page rather than a bare response. Deploys and previews run through +// Workers Builds, see wrangler.toml. import { health } from "./api/health.js"; diff --git a/wrangler.toml b/wrangler.toml index 45bee42..45312c7 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -4,10 +4,20 @@ # Local preview with the Workers runtime: wrangler dev # Validate without uploading: wrangler deploy --dry-run --outdir /tmp/lwoj-dry # -# Production deploys from .github/workflows/deploy.yaml on every merge to main, and every -# pull request gets its own Preview (wrangler preview --name pr-N). The custom domain is -# added in the dashboard when O.J. cuts DNS over from GitHub Pages; until then the Worker -# answers on workers.dev only, so nothing here can change where learnwithoj.com points. +# Deploys run on Cloudflare's side through Workers Builds, connected to this repo in the +# dashboard. A push to main deploys production, a push to any other branch creates or +# updates a Preview at a stable URL, and the Cloudflare GitHub app posts that URL on the +# pull request. No Cloudflare credential lives in GitHub, which is the point: a workflow +# that holds a deploy token can be rewritten by any branch that runs it (Codex, PR 42). +# +# Dashboard build settings, Settings > Build on the Worker: +# Build command (empty, there is no build step) +# Deploy command npx wrangler deploy --var COMMIT_SHA:$WORKERS_CI_COMMIT_SHA --var BRANCH:$WORKERS_CI_BRANCH +# Preview command npx wrangler preview +# +# The custom domain is added in the dashboard when O.J. cuts DNS over from GitHub Pages; +# until then the Worker answers on workers.dev only, so nothing here can change where +# learnwithoj.com points. name = "learnwithoj-com" main = "functions/worker.js" @@ -30,6 +40,10 @@ not_found_handling = "404-page" [observability] enabled = true +# Lets /api/health report which version is answering, with no deploy-time wiring. +[version_metadata] +binding = "CF_VERSION_METADATA" + # Previews use the top-level configuration as is. Give a binding its own preview resource # under this table (for example a separate D1 database) the day production gets one. [previews] From 0f602c1e95f424d8f7f5e4f2ed3e5c053f498189 Mon Sep 17 00:00:00 2001 From: Tern Date: Thu, 12 Nov 2026 09:59:10 -0500 Subject: [PATCH 5/6] wrangler: previews carry the commit vars and the version binding too Codex's two P2s on PR 42. The preview command passes COMMIT_SHA and BRANCH the same way the deploy command does, and the previews table repeats the version_metadata binding, because API bindings are not inherited there. /api/health now reports the same three fields on a Preview as on production. Agent-Session: https://claude.ai/code/session_01YWyGCmBWG4ubvKVLmq9QvM Model: claude-fable-5-1 --- wrangler.toml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wrangler.toml b/wrangler.toml index 45312c7..dd80251 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -13,7 +13,7 @@ # Dashboard build settings, Settings > Build on the Worker: # Build command (empty, there is no build step) # Deploy command npx wrangler deploy --var COMMIT_SHA:$WORKERS_CI_COMMIT_SHA --var BRANCH:$WORKERS_CI_BRANCH -# Preview command npx wrangler preview +# Preview command npx wrangler preview --var COMMIT_SHA:$WORKERS_CI_COMMIT_SHA --var BRANCH:$WORKERS_CI_BRANCH # # The custom domain is added in the dashboard when O.J. cuts DNS over from GitHub Pages; # until then the Worker answers on workers.dev only, so nothing here can change where @@ -44,6 +44,8 @@ enabled = true [version_metadata] binding = "CF_VERSION_METADATA" -# Previews use the top-level configuration as is. Give a binding its own preview resource -# under this table (for example a separate D1 database) the day production gets one. -[previews] +# Previews do not inherit API bindings from the top level, so each one a Preview needs is +# repeated here. Give a storage binding its own preview resource under this table (for +# example a separate D1 database) the day production gets one. +[previews.version_metadata] +binding = "CF_VERSION_METADATA" From 3434f20a6c96bcb9186bac83b44fdfc1549c9bd4 Mon Sep 17 00:00:00 2001 From: Tern Date: Thu, 12 Nov 2026 10:07:39 -0500 Subject: [PATCH 6/6] deploy: previews build in a dev Cloudflare account, production builds main only Her call 12 November on Codex's second security finding. A preview build runs the branch's code with the account's build token, so previews move to an account where that token reaches nothing in production. The production account builds main alone and owns the domain. The merge is the promotion. The config file is the same for both. Agent-Session: https://claude.ai/code/session_01YWyGCmBWG4ubvKVLmq9QvM Model: claude-fable-5-1 --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- SECURITY.md | 6 ++++-- wrangler.toml | 19 +++++++++++++------ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a48e09d..f8a2c04 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,7 @@ Vercel, not "good enough". - `functions/`, the Worker and its `/api/*` routes (`/api/health` today, Stripe webhook and signed downloads later) - `.assetsignore`, what stays out of the asset upload, so the docs and tools above never reach the site - `tools/`, the checks (`tools/check`, `tools/last-reviewed`, `tools/policy-pii`) -- `.github/workflows/`, `checks.yaml` runs the checks on every PR, `ci.yaml` is GitHub Pages until DNS moves, `actions.lock` pins every action to a commit. Deploys and previews run through Cloudflare Workers Builds, not here, so no Cloudflare credential is in GitHub +- `.github/workflows/`, `checks.yaml` runs the checks on every PR, `ci.yaml` is GitHub Pages until DNS moves, `actions.lock` pins every action to a commit. Deploys and previews run through Cloudflare Workers Builds, not here, so no Cloudflare credential is in GitHub. Previews build in a dev Cloudflare account, production builds from `main` in a separate one ## How to run diff --git a/CHANGELOG.md b/CHANGELOG.md index ac75461..070faae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ The format is inspired by [Keep a Changelog](https://keepachangelog.com), and th ## [Unreleased] ### Added - Cloudflare Workers hosting. `functions/worker.js` serves the static site and runs first under `/api/*`, `.assetsignore` keeps the docs, tools and configs off the site (GitHub Pages served `CLAUDE.md` and `wrangler.toml` to anyone who asked), and `/api/health` reports the deployed commit -- Deploys through Cloudflare Workers Builds. Every branch gets its own Workers Preview at a stable URL, posted on the PR by the Cloudflare app, and a merge to `main` deploys production. No Cloudflare credential lives in GitHub, after Codex's security review of PR #42 showed that a preview job holding a deploy token can be rewritten by any branch that runs it. GitHub Pages keeps serving the domain until DNS moves +- Deploys through Cloudflare Workers Builds from two accounts. A dev account builds every branch, so each PR gets a Workers Preview at a stable URL posted on the PR by the Cloudflare app, and a production account builds `main` only. No Cloudflare credential lives in GitHub, and the preview build token has no production authority, after Codex's security review of PR #42 showed that whatever builds an unreviewed branch with a deploy credential can be made to leak it. GitHub Pages keeps serving the domain until DNS moves - The Checks workflow gains two jobs. One lints the workflows (actionlint, zizmor) and verifies `actions.lock`. One fails any PR that changes `agents/` unless its title starts with `regenerate /agents` - `actions.lock` pins every action to a commit (GitHub workflow lockfiles, GA 28 October 2026), Dependabot updates the actions weekly, and an OpenSSF Scorecard workflow publishes the badge in the README - `SECURITY.md` with private vulnerability reporting, current site boundaries and security review guidance diff --git a/CLAUDE.md b/CLAUDE.md index 3386622..88a733e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -52,7 +52,7 @@ The site itself is the proof of capability. Every visitor is making a snap judgm - Plain HTML, CSS, vanilla JS. No framework, no build step, no bundler. - Hosted on Cloudflare Workers with static assets. `wrangler.toml` is the Worker config, `functions/worker.js` is the Worker, and `.assetsignore` keeps the repo's internals off the site. `wrangler dev` previews the site with the Workers runtime. GitHub Pages (`ci.yaml`, `CNAME`) keeps serving learnwithoj.com until O.J. cuts DNS over to the Worker, then both go. -- Dev environment, since 12 November 2026. Workers Builds is connected to this repo on Cloudflare's side, so a push to main deploys production and every other branch gets its own Workers Preview at a stable URL, posted on the PR by the Cloudflare GitHub app. No Cloudflare credential lives in GitHub. A PR is a complete thing. Put the preview link in the description, O.J. and Codex comment on the preview, iterate on the branch, she merges, and main deploys to production. +- Dev environment, since 12 November 2026. Two Cloudflare accounts watch this repo through Workers Builds. The dev account builds every branch, so each PR gets a Workers Preview at a stable URL, posted on the PR by the Cloudflare GitHub app, and main gets a dev mirror. The production account builds main only and owns the domain. A preview build runs the branch's code with the account's token, which is why previews live where that token has no production authority. No Cloudflare credential lives in GitHub. A PR is a complete thing. Put the preview link in the description, O.J. and Codex comment on the preview, iterate on the branch, she merges, and main deploys to production. - Deploys via `.github/workflows/ci.yaml` on push to `main`. - Stripe Checkout for paid B2C services (links live in `index.html` `#pricing`). Not used on B2B pages. - Kit (ConvertKit) for the email-gated AI guide. Form UID: `36c7f50077`. diff --git a/SECURITY.md b/SECURITY.md index 74bbf03..b8522b8 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -20,8 +20,10 @@ DNS moves to the Worker. The Workers deploy uploads the root as static assets mi Worker runs first only under `/api/*`. The implemented route is `/api/health`, which returns a health flag, the serving Worker version and the deployed commit and branch with `Cache-Control: no-store`. Deploys run through Cloudflare Workers Builds on Cloudflare's side, -so no Cloudflare credential is stored in this repository or available to its workflows. Every -branch gets a public Workers Preview on `workers.dev`, sent with `X-Robots-Tag: noindex`. +so no Cloudflare credential is stored in this repository or available to its workflows. Preview +builds run in a dev Cloudflare account whose build token has no authority over production, and +the production account builds `main` only. Every branch gets a public Workers Preview on the dev +account's `workers.dev`, sent with `X-Robots-Tag: noindex`. Approved Stripe Checkout links and the Kit form are live B2C integrations. Their providers handle the current checkout and email submission flows. This repo does not currently diff --git a/wrangler.toml b/wrangler.toml index dd80251..e8dcdee 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -4,13 +4,20 @@ # Local preview with the Workers runtime: wrangler dev # Validate without uploading: wrangler deploy --dry-run --outdir /tmp/lwoj-dry # -# Deploys run on Cloudflare's side through Workers Builds, connected to this repo in the -# dashboard. A push to main deploys production, a push to any other branch creates or -# updates a Preview at a stable URL, and the Cloudflare GitHub app posts that URL on the -# pull request. No Cloudflare credential lives in GitHub, which is the point: a workflow -# that holds a deploy token can be rewritten by any branch that runs it (Codex, PR 42). +# Deploys run on Cloudflare's side through Workers Builds, from two Cloudflare accounts +# connected to this one repo, O.J.'s call 12 November 2026 after Codex's security review: # -# Dashboard build settings, Settings > Build on the Worker: +# production account builds main only, preview builds off. Owns learnwithoj.com. +# dev account builds every branch. Each branch gets a Preview at a stable URL, +# the Cloudflare GitHub app posts it on the pull request, and main +# gets a dev mirror of production. Holds nothing a visitor reaches. +# +# A preview build runs the branch's code with that account's build token, so previews live +# in an account where the token has no production authority. No Cloudflare credential lives +# in GitHub at all. The merge to main is the promotion from dev to production, and the +# ruleset on main is what gates it. +# +# This file is the same for both accounts. Dashboard build settings, Settings > Build: # Build command (empty, there is no build step) # Deploy command npx wrangler deploy --var COMMIT_SHA:$WORKERS_CI_COMMIT_SHA --var BRANCH:$WORKERS_CI_BRANCH # Preview command npx wrangler preview --var COMMIT_SHA:$WORKERS_CI_COMMIT_SHA --var BRANCH:$WORKERS_CI_BRANCH