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
Cyb3r-Jak3
Cyb3r-Jak317mo ago
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>
mb0x88
mb0x88OP17mo ago
yes but i want to be able to deploy to production from --branch test
Cyb3r-Jak3
Cyb3r-Jak317mo ago
Then you'd do --branch <production branch> on something that normally wouldn't be the production branch
mb0x88
mb0x88OP17mo ago
this 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?
Cyb3r-Jak3
Cyb3r-Jak317mo ago
What command are you running? If you don't specify a branch it will default to main
mb0x88
mb0x88OP17mo ago
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
Cyb3r-Jak3
Cyb3r-Jak317mo ago
Then yeah I would expect to see that in the dashboard and what you are doing is correct.
Want results from more Discord servers?
Add your server