How to deploy to Production environment via wrangler / CI?

I’m trying to deploy to Pages via direct upload from CI, as documented here:

https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/

I’m calling wrangler2 pages publish public --project-name=my-project-name from CI, which successfully deploys the contents of the public dir to a new preview environment.

However, all my deployments are listed as going to the “Preview” environment, and are available on (i.e.) https://some-tag-ref.my-project-name.pages.dev/

I get a 522 error page on the “Production” URL at (i.e.) https://my-project-name.pages.dev/

How do I alter the wrangler command to deploy to the “Production” environment? The command docs don’t seem to include any such argument.

You would have set the production branch when creating the project and then wrangler will pick up your current branch if it’s in a Git directory.

If not, specify it with --branch as an argument to publish

Hi - thanks for the reply, it doesn’t seem to have worked though. I’ve tried --branch=main and --branch=master, both result in successful deploys to the “Preview” environment with those branch names as the source.

The project isn’t connected to a git repo, I selected “Direct Upload” when creating the project, and wasn’t given the option to set a default branch for Production. I don’t see anywhere now that I can set it.

That means the branch has defaulted to “production”. So --branch=production.

Ah of course it’d be the one I didn’t try! Many thanks :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.