Skip to content

ci(store): a merge to main deploys the store, migrations first - #19

Merged
HalfSweet merged 1 commit into
mainfrom
ci-deploy-store
Nov 12, 2026
Merged

HalfSweet merged 1 commit into
mainfrom
ci-deploy-store

Conversation

@HalfSweet

Copy link
Copy Markdown
Member

Every deployment of the store was made by hand with wrangler, and main ran ahead of what was live (nine days, once, with a removed route still being served). This makes a merge the release.

What the workflow does

.github/workflows/store.yml, on a change to store/, lib/ (the Worker reads lib/mock.ts), the lockfile or the workflow itself:

  • On a pull request: type-checks the website and runs the store's tests. No deploy, and no secrets are used.
  • On main: the same checks, then wrangler d1 migrations apply --remote, then wrangler deploy, which builds the website first. One deploy at a time, in the order the merges came.
  • By hand (workflow_dispatch): deploys main again.

It does not need the pocketjs submodule or Rust, so it does not run the whole bun run check; that stays a local step. The two actions are pinned to the commits their release tags name (actions/checkout v7.0.1, oven-sh/setup-bun v2.2.0).

What was decided

  • Migrations run automatically, before the Worker, with no one asked. Nothing sorts the ones that only add from the ones that take away. docs/applets.md says how to write one for that order.
  • A deploy that goes wrong is put right by hand. The same section has the commands: wrangler rollback, and D1's time travel for the database.

Already done, outside this pull request

  • main is protected: changes come through pull requests only, admins included; no approval is required, force pushes and deletion are off, and no status check is required (a check that only runs for some paths would block every pull request that does not touch them).
  • The secret CLOUDFLARE_ACCOUNT_ID is set.

Needed before this is merged

The secret CLOUDFLARE_API_TOKEN does not exist yet. It has to be made in the Cloudflare dashboard (Workers Scripts, Workers Routes and D1, edit, on the account that holds omarchy-pocket-store) and stored with gh secret set CLOUDFLARE_API_TOKEN. Without it the checks pass and the deploy step fails; nothing is deployed and nothing is harmed.

What merging does

Merging this touches the workflow's own path, so it starts a deploy of main: with the token in place that puts #18 (the Chinese site) live. The live database has no migration waiting.

Verified

  • In a clean copy of main with no submodule and no node_modules: bun install --frozen-lockfile, bun run typecheck:site and bun test ./store/test pass; wrangler d1 migrations list --remote finds nothing to apply; wrangler deploy --dry-run builds and bundles with the workflow's own command line.
  • The check job runs on this pull request.
  • Not verified: the deploy job. It cannot run before the merge, and the token it needs does not exist yet. The protection was read back from GitHub, not tested by trying to push to main.

Every deployment of the store was made by hand with wrangler, and main ran
ahead of what was live (nine days, once, with a removed route still being
served). .github/workflows/store.yml now deploys it when main changes
store/, lib/ (the Worker reads lib/mock.ts) or the lockfile: it type-checks
the website, runs the store's tests, applies the migrations the live
database has not had, and deploys the Worker with its website. A pull
request that touches the same paths gets the checks and no deploy, and the
workflow can be run by hand to deploy main again. None of it needs the
pocketjs submodule.

Migrations run before the Worker with no one asked, and nothing sorts the
ones that only add from the ones that take away: a merge is a release, and
a deploy that goes wrong is put right by hand. docs/applets.md says how to
write a migration for that order, and how to roll a deploy or the database
back.

The deploy reads two repository secrets, CLOUDFLARE_API_TOKEN (Workers
Scripts, Workers Routes and D1, edit) and CLOUDFLARE_ACCOUNT_ID. The actions
are pinned to the commits their release tags name.
@HalfSweet
HalfSweet merged commit 4d7247b into main Nov 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant