Can I use wrangler pages deploy command to create a project if it doesn't exist?


I found this sentence in the docs:

If you would like to streamline the project creation and asset deployment steps, you can also use the deploy command to both create and deploy assets at the same time.

but I cannot get that to work. When I run this (project test does not exist):

npx wrangler pages deploy build/client -e production --branch main --project-name=test

I get the following error:

[ERROR] A request to the Cloudflare API (/accounts/***/pages/projects/test) failed.

Project not found. The specified project name does not match any of your existing projects. [code: 8000007]

which seems to conflict with the text in the docs. Am I missing something or are the docs outdated?

Thank you!

I just realized I should mention this: I was doing it in a Github Action using this action: wrangler-action/action.yml at main · cloudflare/wrangler-action · GitHub. I believe that one doesn’t support it, as locally I can kind of get there as I get this prompt when I run the command:

$ npx wrangler pages deploy build/client -e production --branch main --project-name=timotei-test
The project you specified does not exist: “timotei-test”. Would you like to create it?"
❯ Create a new project

So, my updated question is, can I do this in that github action, and can I default it to say yes since I cannot interact with it on CI?