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
24 changes: 8 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ jobs:
- run: npm run check
- run: npm test
- run: npm run build
# Migration 0001 is already applied remotely. Keep deployment fail-closed
# until a separately least-privileged D1 token exists for future changes.
- name: Verify production D1 migration baseline
shell: bash
run: |
test "$(find worker/migrations -maxdepth 1 -type f -name '*.sql' | wc -l)" -eq 1
echo "3f820cb7c1f8e76196e83f8bc8448dd9e72e840884fc39641c84e6b9d60ff27f worker/migrations/0001_pegma_storage.sql" |
sha256sum --check --strict
- name: Deploy to Cloudflare Pages
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand All @@ -37,22 +45,6 @@ jobs:
npx wrangler pages deploy dist
--project-name pegma-dev
--branch main
# Same triggers as production Pages (push/schedule/dispatch on main).
# Token must include Workers Edit and D1 Edit in addition to Pages Edit — see
# docs/PROJECT_PLAN.md Phase 2.
- name: Apply pegma-dev-identity D1 migrations
if: >
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch')
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: >
npx wrangler d1 migrations apply IDENTITY_DB
--remote
-c worker/wrangler.jsonc
- name: Deploy pegma-dev-api Worker
if: >
github.ref == 'refs/heads/main' &&
Expand Down
10 changes: 6 additions & 4 deletions docs/PROJECT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ Actions deploy (SHA-pinned, per ecosystem standard).
Exit: push-to-main publishes; the domain serves the site with an A grade on
the obvious security headers. **Done:** project `pegma-dev`, deploys via
plain `npx wrangler` in the SHA-pinned workflow (the CI token is scoped to
Pages:Edit, Workers:Edit, and D1:Edit — deliberately no DNS scope; the custom
Pages:Edit and Workers:Edit — deliberately no D1 or DNS scope; the custom
domain was attached in the dashboard); security headers served from
`public/_headers`, CSP with same-origin scripts only; `www` 301s to the apex.
Pull requests run the build gate but never receive that production token;
branch previews remain disabled until a separately scoped preview credential
exists.
The initial D1 migration was operator-applied and production CI pins its exact
hash; a future schema change remains fail-closed until it has a separate
least-privileged D1 credential. Pull requests run the build gate but never
receive the production token; branch previews remain disabled until a
separately scoped preview credential exists.

### Phase 3 — the compiled roadmap ✓ (2026-07-27)

Expand Down
11 changes: 7 additions & 4 deletions worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ npx wrangler secret put DATADOG_SITE -c worker/wrangler.jsonc
```

CI deploys this Worker with the same `CLOUDFLARE_API_TOKEN` as Pages; that
token needs **Workers:Edit** and **D1:Edit** in addition to **Pages:Edit**.
token needs **Workers:Edit** in addition to **Pages:Edit**. It intentionally
does not receive D1 authority.

## Identity composition

Expand Down Expand Up @@ -82,9 +83,11 @@ and must remain stable while any email-code or Mail job is live. Verify the
The D1 schema is deployment-managed by
`migrations/0001_pegma_storage.sql`. The adapter runs with
`createSchemaIfMissing: false`, so request traffic never performs DDL.
Production CI applies pending migrations before activating a new Worker
version. The versioned route is limited to `pegma.dev/api/*`; Cloudflare Pages
continues to serve every static path.
Migration 0001 was applied to production before Worker activation. Production
CI verifies that exact frozen baseline byte-for-byte; any future migration
fails that gate until a separately least-privileged D1 deployment credential
and migration step are reviewed. The versioned route is limited to
`pegma.dev/api/*`; Cloudflare Pages continues to serve every static path.

Passkey removal stays disabled until an email-code recovery implementation is
live. This deliberately avoids a last-factor lockout in the passkey-only
Expand Down