cloudflare / wrangler-action

🧙‍♀️ easily deploy cloudflare workers applications using wrangler and github actions
Apache License 2.0
1.26k stars 159 forks source link

fix: Use wrangler secret put instead of deprecated secret:bulk command #328

Closed jahands closed 5 days ago

jahands commented 5 days ago

wrangler secret:bulk is deprecated and will be removed in a future version.

This improves logging in cases where a secret is failing to upload because an environment variable with the same name already exists (see: #240). Example:

Screenshot 2024-11-18 at 9 41 21 AM

With this change, we get this:

Screenshot 2024-11-18 at 9 35 43 AM

Testing:

Tested with a repo where the Worker already contains a secret of a different type: https://github.com/jahands/wrangler-action-example/actions/runs/11895527967/job/33145312742

Maximo-Guk commented 5 days ago

We now have some baby tests in wranglerAction.test.ts #322 , so it's possible to write some tests for uploadSecrets() if you're so inclined!

Cherry commented 5 days ago

Yeah, this would be a pretty major behavioural change to revert to the old method of setting individual secrets. Using wrangler secret put for tens of secrets within a worker can result in errors from the API since they're run in parallel and sometimes don't get acknowledged quickly enough and then cause a mismatch, as well as that many individual new deploys of your worker, cluttering up the versions list. Not to mention drastically slow down the deploy time too.

jahands commented 5 days ago

Closing as this was not the right way to fix this. Looking into improving logging in bulk puts