Preview deployments URLs
Hey folks,
Context:
I'm migrating my project from Pages to Workers (SvelteKit site).
Branch control >
Pull request previews: Enabled(default)
Version command: npx wrangler versions upload(default)
Issue:
While building the preview deployment of my PR branch: invalid alias: HEAD [code: 10021]
What I tried:
Changing the command to get a bit more infos on what's going on:
Logs:
CF_BRANCH=feat-preview-worker-2
GIT_BRANCH=HEAD
WARNING: no branch context
ALIAS=feat-preview-worker-2
So it seems the issue it that the git branch is not present (because CF check out the commit not the branch ?), so HEAD is taken instead, which seems to lead to the error.
So far it "works" here because I write the alias here with that command, but its not the nominal way of doing I guess...
Any ideas ? Thanks for your help! 🙂10 Replies
Hey @Hugo , we had a big in a previous version of workers ( I can't recall which, but I think it was 4.2X?). If you upgrade your version of wrangler to latest, you'll definitely have the fix!
Hey! Thanks for your reply 🙂
Don’t the Cloudflare remote using the latest version of Wrangler ? I do not have the wrangler lib in my dev dependencies in my package.json
Hmm.. then yeah it should be picking up the latest. What do your build logs say?
Code-wise, we set WORKERS_CI_BRANCH and then workers-sdk picks that up
https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/versions/upload.ts#L996
GitHub
workers-sdk/packages/wrangler/src/versions/upload.ts at main · clo...
⛅️ Home to Wrangler, the CLI for Cloudflare Workers® - cloudflare/workers-sdk
Logs saying:
invalid alias: HEAD [code: 10021]
Using the default: npx wrangler versions upload
What version of wrangler?
Oh actually it shows 4.19.1 !
I’m gonna install the latest dev dep, so it should take the version from that I guess
🙂 that'll do it
Report back, let me know!
It works!! Thanks for your help 🙂
Any other thing to pay attention while we are talking about Worker deployment from a Pages project ? E.g all my Rules and CF setups will works as usual as long the Worker is deployed under the domain I guess ?
yep, if you already have setup done on a zone, as long as the Worker also runs in that zone, everything will run the same
Great, thanks!