cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.6k stars 674 forks source link

🚀 Feature Request: Pages: Allow default branch (e.g. `main`) to be deployed to production OR preview env #6066

Closed majames closed 3 months ago

majames commented 3 months ago

Describe the solution

I want to be able to be able to deploy my pages project default branch (main) to both the preview or production env depending upon whether I set the --env CLI flag (similar to workers).

I attempted to "hack" this using the --branch CLI flag but that resulted in the following error when attempting to deploy on main:

# attempting to deploy "main" branch (checked out) to pages preview env
$ git branch --show-current
main
$ wrangler pages deploy --branch preview 
...
✨ Compiled Worker successfully
✨ Uploading Worker bundle
✨ Uploading _routes.json
🌎 Deploying...

✘ [ERROR] Deployment failed!

  Failed to publish your Function. Got error: Unknown internal error occurred.
majames commented 3 months ago

Ah, turns out that the reason the deploy was failing because i'd misconfigured the D1 database_id in my preview env. So I think the --branch hack might actually work

majames commented 3 months ago

Confirmed, the --branch hack works for changing the pages deploy env even when running on main