workers-sdk
workers-sdk copied to clipboard
🐛 BUG: GitHub action failing with environment
What version of Wrangler
are you using?
2.0.23
What operating system are you using?
Mac
Describe the Bug
I'm using GitHub actions to deploy workers to different environments. But I'm getting an error as follows (though the worker is deployed correctly).
Using API Token authentication
$ Running: wrangler publish --env staging
⛅️ wrangler 2.0.23
--------------------
▲ [WARNING] Processing wrangler.toml configuration:
- 😶 Ignored: "type":
Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
- Deprecation: "zone_id":
This is unnecessary since we can deduce this from routes directly.
- Unexpected fields found in top-level field: "format"
Total Upload: 8.24 KiB / gzip: 2.46 KiB
Worker ID: optimizer-staging
Worker ETag: 3a3a8f22a65093324d091b67d22dad172e5fd555289bf604b8b226290fcd9fe3
Uploaded optimizer-staging (0.61 sec)
✘ [ERROR] A request to the Cloudflare API (/accounts/xyz/workers/scripts/optimizer-staging/routes) failed.
workers.api.error.duplicate_route [code: 10020]
wrangler.toml
name = "optimizer"
type = "javascript"
format = "service-worker"
main = "./src/index.js"
account_id = "abc"
zone_id = "xyz"
compatibility_date = "2022-04-13"
usage_model = "bundled"
[env.production]
name = "optimizer-production"
route = { pattern = "*/*", zone_id = "xyz" }
[env.staging]
name = "optimizer-staging"
route = { pattern = "*/*", zone_id = "xyz" }
deploy.yml
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v3
- name: Publish
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
command: publish --env staging
The error code specifies what's going on here, you're trying to deploy the worker to the same route in both production and staging environments, which is not what you probably want.
@threepointone tried different route, but same error.
wrangler.toml
name = "optimizer"
type = "javascript"
format = "service-worker"
main = "./src/index.js"
account_id = "abc"
zone_id = "xyz"
compatibility_date = "2022-04-13"
usage_model = "bundled"
[env.production]
name = "optimizer-production"
route = { pattern = "*/*", zone_id = "xyz" }
[env.staging]
name = "optimizer-staging"
route = { pattern = "*example.com/*", zone_id = "xyz" }
It's possible that you've already deployed another worker to those routes. You'll have to remove them from the dashboard before publishing with wrangler again.
@threepointone tried deleting, but still no luck. I'm using the same .toml file with buddy.works, and it deploys fine!
You'll have to check, that's what the error means. There's a worker already deployed to the route.
@threepointone, what if I want to overwrite/update? The worker in production cannot be deleted.
You can deploy a worker with the same name to that route. I'm suggesting you change the staging one to another route that doesn't overlap with the production one.
I deleted the entire staging worker and its routes. Still not working.
I can't help you debug a usage problem here I'm afraid. This is definitely not a wrangler issue though. I'd recommend asking in discord, with more details of the wrangler.toml without substitutions.
Also I would check that you don't happen to have another completely separate worker wired up to the same route.
Let us know if you were able to get support in the Discord.
https://discord.gg/cloudflaredev