Change production branch name for pages direct deployment

Hey all, I've been deploying my pages projects using github actions (wrangler cli / wrangler action). I'm in the process of changing github repositories for the projects and as a result of this, the "default" production branch name has changed from master to main. However, when I do a deployment using wrangler pages deploy public/ it makes a preview deployment on the main branch. This makes sense since the default branch is configured to be master. Does anyone know how to change the "default" branch for a pages project? I poked around in the settings but couldn't find anything. Relevant info - account id: 87a3c637ba57424b09104e5ade4caffe
3 Replies
Adi
AdiOP10mo ago
Never mind, I found the solution on GitHub. For anyone who comes across this, the following curl command works
curl --request PATCH --url https://api.cloudflare.com/client/v4/accounts/YOUR_ACCOUNT_IDENTIFIER_HERE/pages/projects/YOUR_PROJECT_IDENTIFIER_HERE --header 'Content-Type: application/json' --header 'Authorization: Bearer YOUR_API_TOKEN_HERE' --data '{ "production_branch": "YOUR_PRODUCTION_BRANCH_HERE" }'
curl --request PATCH --url https://api.cloudflare.com/client/v4/accounts/YOUR_ACCOUNT_IDENTIFIER_HERE/pages/projects/YOUR_PROJECT_IDENTIFIER_HERE --header 'Content-Type: application/json' --header 'Authorization: Bearer YOUR_API_TOKEN_HERE' --data '{ "production_branch": "YOUR_PRODUCTION_BRANCH_HERE" }'
Github comment reference - https://github.com/cloudflare/pages-action/issues/63#issuecomment-1513903702
Torque
Torque10mo ago
You can create a production deployment from any branch by overriding the branch name to the one which is the default branch for production deployment. E.g. if I have checked out stage branch and I want to create a production deployment from this branch, then it can be achieved by executing wrangler pages deploy ./dist --project-name <project_name> --branch main command from the current branch.
Hebilicious
Hebilicious9mo ago
This should be in the docs https://developers.cloudflare.com/api/operations/pages-project-update-project Looks like the API docs are not displaying the parameters properly
Want results from more Discord servers?
Add your server