Authenticating with multiple CF accounts for wrangler

Hi,

I’m puzzled how to publish several workers sites to different Cloudflare accounts.

I’m not talking about several zones under one CF account or even several users under one account, but about completely different Cloudflare accounts.

We have to keep it that way due to compliancy reasons, but I guess this can be applied to a contractor that works with several customers that have different CF accounts.

The problem is that ~/.wrangler/config/default.toml holds only one set of credentials and even if I move & edit them to project’s wrangler.toml they don’t seem to work there.

I do see that there is a way to use env variables but this is clearly subpar to --env flag that already allows to specify different sections of .toml file to use. Why api_token directive isn’t working there?

you could use Environment Variable CF_API_TOKEN

- name: Publish Worker
  run: npx wrangler publish
  env:
    CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}

As I’ve indicated in the OP I’m aware of this.

This may be convenient for automated deployment system like Github Actions or Gitlab Runner, but it’s awkward to use for manual deployments.

The problem is that wrangler uses several .toml files for configuration and they are parsed inconsistently. Why is ~/.wrangler/config/default.toml coded as special case and directives from it are not usable in project-level files?