Add bunny.net edge script + deploy workflow (geo-pricing, deployable half) - #13
Closed
taobojlen wants to merge 1 commit into
Closed
Add bunny.net edge script + deploy workflow (geo-pricing, deployable half)#13taobojlen wants to merge 1 commit into
taobojlen wants to merge 1 commit into
Conversation
Adds the bunny.net middleware edge script that rewrites the displayed price based on the visitor's country (CDN-RequestCountryCode), plus the manual workflow to deploy it. This is the deployable half of geo-localized pricing; the website changes (data-price markers) arrive separately. Edge script (edge-script/): - Middleware using servePullZone + HTMLRewriter. Non-UK visitors get $35/year; UK/unknown visitors see the static default (£25/year) baked into the HTML. Safe degradation if the script is disabled or the header is missing. - Bundled to a single file via esbuild + @luca/esbuild-deno-loader (mirrors the official BunnyWay template). Deploy: - deploy-edge-script.yml: manual-dispatch workflow. Type-checks, bundles, and uploads the edge script to a bunny edge script id. Secrets: BUNNY_STAGING_SCRIPT_ID / BUNNY_STAGING_DEPLOY_KEY. The script is generic and safe to merge independently: it only rewrites elements with data-price="" attributes, which don't exist on the site yet (those arrive with the website changes). Until then it's a no-op on every page, so merging this first carries no risk.
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.
What
The bunny.net middleware edge script that rewrites the displayed price based on the visitor's country (
CDN-RequestCountryCode), plus the manual GitHub workflow to deploy it.data-priceelements)Why split from #10
Manual workflows (
workflow_dispatch) only run frommain. To test the edge script end-to-end (deploy it → attach to staging pull zone → verify the rewrite), the workflow file needs to be onmainfirst. Same pattern that worked for the staging site deploy.Safe to merge independently
The script only rewrites elements with
data-price=""attributes. Those attributes don't exist on the site yet (they arrive in the companion website PR #10). Until then, the script is a no-op on every page — it runs, finds nothing to rewrite, passes the response through. Merging this first carries no risk.Files
Edge script (
edge-script/):src/pricing.ts— middleware: readscdn-requestcountrycode, rewrites[data-price]for non-UK viaHTMLRewritersrc/main.ts— entry pointsrc/bunny-globals.d.ts— ambient types forHTMLRewriter(bunny runtime global)build.mjs+deno.json— esbuild bundle to singledist/index.tsREADME.md— full setup/deploy/verify docsDeploy:
.github/workflows/deploy-edge-script.yml— manual-dispatch: type-check + bundle + upload (secrets:BUNNY_STAGING_SCRIPT_ID,BUNNY_STAGING_DEPLOY_KEY)Verified
deno check src/main.ts✅deno task build✅Test plan (merge order)
deploy-edge-script.ymllands onmain.edge-script/README.md).BUNNY_STAGING_SCRIPT_ID+BUNNY_STAGING_DEPLOY_KEY.main).data-pricemarkers) + re-deploy the staging site → full geo-pricing test.