Repository navigation
ci(store): a merge to main deploys the store, migrations first - #19
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every deployment of the store was made by hand with
wrangler, andmainran 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 tostore/,lib/(the Worker readslib/mock.ts), the lockfile or the workflow itself:main: the same checks, thenwrangler d1 migrations apply --remote, thenwrangler deploy, which builds the website first. One deploy at a time, in the order the merges came.workflow_dispatch): deploysmainagain.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/checkoutv7.0.1,oven-sh/setup-bunv2.2.0).What was decided
docs/applets.mdsays how to write one for that order.wrangler rollback, and D1's time travel for the database.Already done, outside this pull request
mainis 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).CLOUDFLARE_ACCOUNT_IDis set.Needed before this is merged
The secret
CLOUDFLARE_API_TOKENdoes not exist yet. It has to be made in the Cloudflare dashboard (Workers Scripts, Workers Routes and D1, edit, on the account that holdsomarchy-pocket-store) and stored withgh 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
mainwith no submodule and nonode_modules:bun install --frozen-lockfile,bun run typecheck:siteandbun test ./store/testpass;wrangler d1 migrations list --remotefinds nothing to apply;wrangler deploy --dry-runbuilds and bundles with the workflow's own command line.main.