Deploy to pages specifying production or preview from a gitlab CI/CD pipeline
We have a CI/CD pipeline that publishes our repo to cloudflare pages from a private gitlab, however I want to be able to select preview or production using gitlab, not the default system where it uses preview builds for extra branches until you merge into main.
How do i achieve this? Is there a way to pass an environment variable from gitlab to cloudflare pages to specify which environment to publish to preview or production?
7 Replies
If you pass
--branch <not your production branch>
it will create a preview deployment.
So something like wrangler pages deploy <directory> --project-name <your project> --branch <fake>
yes but i want to be able to deploy to production from --branch test
Then you'd do
--branch <production branch>
on something that normally wouldn't be the production branchthis i find a bit confusing, because im pushing my random branch without merging into main and it shows up as main in the cf dashboard? is this the only way to do it?

What command are you running? If you don't specify a branch it will default to main
i have a test branch i want to push to production without merging into main, im using the --branch main flag on my test branch, and that is the result - am i understanding this corrctly? or is it pushing the main branch not my test branch
Then yeah I would expect to see that in the dashboard and what you are doing is correct.