Closed giladv closed 1 month ago
I am having the same issue. Every push or pr in any branch results in production deployment.
I had the same issue, the workaround is to invoke the API directly to patch the production_branch
field to be the real production branch: https://developers.cloudflare.com/api/operations/pages-project-update-project
workingDirectory
support was only released yesterday, so you should probably try again and see if you're still having this problem.
That said, the production branch name comes from the Cloudflare API, but I'm not sure the value can be changed from main
. I believe that would be a dashboard gap, since that value should still be configurable for direct uploads.
We have multiple branches for multiple deployments and previews (our own version of a preview, that needs to be available directly at our subdomain)- but now anything we run that is not "master" branch (like PR actions etc.) are all being deployed as "preview" which is useless because now those deployments are not visible and live at our subdomain.
I've run into this kind of issue before. I think Cloudflare needs to have good defaults- but always give the option to make a deployment a "production" deployment... Why can't we just provide a flag "--production" or whatever.
I've run into this kind of issue before. I think Cloudflare needs to have good defaults- but always give the option to make a deployment a "production" deployment... Why can't we just provide a flag "--production" or whatever.
You... can. Just specify the branch as your production branch (--branch=<production-branch>
in wrangler)
With this action, it's just
branch: <production-branch>
Would be amazing if there was more documentation about this!
EDIT: Nevermind, I see it in the Readme. My mistake, but would be nice to just have an "options" area that shows all the options available.
Still is set as preview... This DX is really not so great. Now I have to guess what the actual "production" branch is- probably "main". I can't set this anywhere because the page project is a "direct upload" one, because we are using Github Actions.
The idea of a single "production" branch doesn't really work in a lot of cases either.
It'll either be "main" or "production" probably
The idea of a single "production" branch doesn't really work in a lot of cases either.
You have to remember we use to have only Git, not Direct Uploads. Specifying a --production
is the same as a --branch=<prod-branch>
We could technically add an option to just do that but not sure I like that personally (feel free to put up an issue on the Wrangler docs though)
We've managed to win with "main". Its just a lil weird because we don't even have a "main" branch (still using "master" on this repo). So overall, just opening the door for confusion.
I understand that Git was how things originally worked- but surely when it comes to direct uploads, sometimes these won't even be coming from a git repo- an option just to say --production
seems like a no-brainer to me. Should have been there from the get-go.
@WalshyDev I think the CF dash should be updated to let folks change the production branch when the project is set to manual upload. Right now it basically hard-codes to main
, which is not always going to be correct.
IMHO the rest of the functionality is fine here and the only real problem is in the CF dash.
I think the CF dash should be updated to let folks change the production branch when the project is set to manual upload
Yes, it needs to have this indeed. Unfortunately, it's been one of those things that just slipped into the backlog and have not been prioritized. It's on my todo list but things keep taking higher priority.
For anyone else that's bumping into this and wants a quick overview on how to fix up their project's production branch as of right now...
There's two steps required here:
branch: YOUR_PRODUCTION_BRANCH_HERE
is set in your Action's yaml fileproduction_branch
. Here's a helpful cURL (h/t @ari-becker)
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" }'
Replace YOUR_ACCOUNT_IDENTIFIER_HERE
, YOUR_PROJECT_IDENTIFIER_HERE
, YOUR_API_TOKEN_HERE
with your own. All of which can be found or created in your Cloudflare dashboard. Note that YOUR_API_TOKEN_HERE
needs the Cloudflare Pages:Edit
permission.
Replace PRODUCTION_BRANCH_HERE
with your repo's branch (e.g. for me it's trunk
). This should match the branch: PRODUCTION_BRANCH_HERE
set in your Action yaml.
🚀
YOUR_ACCOUNT_IDENTIFIER_HERE
YOUR_PROJECT_IDENTIFIER_HERE
YOUR_API_TOKEN_HERE
YOUR_PRODUCTION_BRANCH_HERE
master
or whatever your actual Git production branch is named instead of the default of main
which has no UI to be changedAfter making those 4 changes, copy and paste it into a Linux terminal (not command prompt, for some reason the API returns an error using the built-in Windows bash). It might be easier/more reliable to remove the \
after each line and make it all one line. As a one-liner for convenience:
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" }'
Important: I found that using the bash
built into Windows didn't work in command prompt. I kept getting errors from the API. Using the exact same command from WSL bash did work, though. Not sure why, but hopefully that helps.
Hey,
So want to use CF pages on a monorepo which the new
workingDirectory
feature was designed for. Problem is, to use with monorepos, project has to be defined as a "direct upload" project which doesn't has a production branch setting in it. The only way to do it is to allow this action to have aproductionBranch
setting which is missing.Please advise.