Environments help in wrangler

I'm having a mental block... I've got a prod env, a staging env and then all the other builds that happen from pull requests.... In wrangler, how do I make it so that builds that happen from a git build done by cloudflare build production / staging / other..... other would have the same vars/bindings as staging . 100% appreciate I'm probably forgetting something super simple....
1 Reply
hisam
hisam4d ago
Assuming that you're using GitHub Actions, you can specify the environment:
steps:
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
environment: production
secrets: |
SECRET1
steps:
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
environment: production
secrets: |
SECRET1
In some cases that requires custom command, can add --env flag (ref):
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
secrets: VERY_SECRET_KEY
command: publish --env production ...some other command
environment: production
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
secrets: VERY_SECRET_KEY
command: publish --env production ...some other command
environment: production
Cloudflare Docs
Commands - Wrangler · Cloudflare Workers docs
Create, develop, and deploy your Cloudflare Workers with Wrangler commands.

Did you find this page helpful?