how to deploy CF Pages of existing static site using CLI, without using GitHub?

I’ve been developing a React project locally and the code is on a local for server not GitHub. I’m trying to create some automation so that using the CLI I can deploy to CF Pages ‘preview’ and promote to ‘production’
I’ve been using wrangler create cloudflare project since wrangler init is no longer supported and I’m having a hard time figuring out how to initialize a Pages project within an existing react project. Ideally all I want to do is programmatically be able to deploy my dist directory and overwrite the existing CF Pages deployments. My initial CF Pages deployment was via direct upload using the web drag and drop method. You can’t update a CF Pages deployment using that method. You need to use the CLI
8 Replies
Walshy
Walshy4mo ago
you can continue using drag & drop to update but wrangler is recommended anyway, wrangler pages deploy <output-dir> e.g. wrangler pages deploy dist This will pick up whatever git branch you're currently on, if you wanted to specify a specific one for like staging vs prod you can do wrangler pages deploy <output> --branch staging (or whatever your staging/production/etc branch is)
javatextbook
javatextbookOP4mo ago
So if my prod deployment is called production and my main prod branch is main, can wrangler deploy directly to that too?
Walshy
Walshy4mo ago
i'm not fully sure the ask but you can deploy to other branches yes
javatextbook
javatextbookOP4mo ago
Oh cloudflare pages website at cloudflare.com there is the production deployment and there’s the preview deployment. Does wrangler always deploy to preview or can you directly deploy to production?
Walshy
Walshy4mo ago
wrangler can deploy to both they're based on the branch, so if your production branch is main, deployments on the main will be production any other branch will be preview again, detected from whatever git branch you're currently on when running the command unless you specify --branch
javatextbook
javatextbookOP4mo ago
Cloudflare Docs
Configuration · Cloudflare Pages docs
If your project contains an existing wrangler.toml file that you previously used for local development, make sure you verify that it matches your …
Walshy
Walshy4mo ago
wrangler.toml is a great way to handle configuration of your project yeah
javatextbook
javatextbookOP4mo ago
Thank you for being so responsive. I will be fiddling around with all of this and I will probably come back here for follow ups.
Want results from more Discord servers?
Add your server