Merged
Conversation
Extend build.yml to also trigger on pull_request events, deploying
preview builds to Cloudflare Workers (static assets). Each PR gets its
own worker (toys-pr-{number}) with a bot comment linking to the preview
URL. A separate cleanup workflow deletes the worker when the PR closes.
- build.yml: add pull_request trigger, conditional VITE_BASE ("/" for
PRs, "/toys/" for main), deploy-preview job with wrangler + PR comment
- preview-cleanup.yml: delete worker on PR close
- wrangler.toml: minimal assets-only config for Cloudflare Workers
https://claude.ai/code/session_015vs1SrQi7gY45GQJBn23w7
|
Preview deploy is ready! https://toys-pr-30.somehats.workers.dev Built from 0718c27 |
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.
Summary
This PR adds preview deployment functionality for pull requests using Cloudflare Workers, while maintaining the existing production deployment pipeline for the main branch.
Key Changes
pull_requestevent trigger to the build workflow for opened, synchronize, and reopened eventsVITE_BASEenvironment variable to use/for PR builds and/toys/for production buildsgithub-pagestobuild-outputfor clarityif: github.event_name == 'push'condition to thedeployjob (renamed todeploy-pages) to ensure it only runs on main branch pushesdeploy-previewjob that:toys-pr-{PR_NUMBER})preview-cleanup.ymlworkflow that automatically deletes preview workers when PRs are closedwrangler.tomlconfiguration file for Cloudflare Workers deploymentImplementation Details
<!-- preview-deploy -->) to enable idempotent updates on subsequent deploymentsCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDsecrets to be configuredhttps://claude.ai/code/session_015vs1SrQi7gY45GQJBn23w7