cloudflare / cloudflare/wrangler-action
Unexpected behavior for pre/post commands using wrangler
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 214
- PR merge metrics
- No merged PRs in 30d
Description
Hej there,
what we do is using the `preCommands` hook to execute `wrangler secret:bulk`.
(Just for some context: in our CI step we need to sync some secrets from an external system towards Cloudflare. Thus we can/do not want to use the very static approach of using the `secrets`/`env` dance in the action definition, because this would mean using GitHub as an intermediary secrets store and having one more place that needs to be kept in sync manually.)
Thing's I've found:
1. Despite the claim in the README, `wrangler` is not available right away in that context, but needs to be invoked via your package manager of choice (kudos & hat tip for recent work on supporting multiple ones 👌)
2. By not differentiating the wrangler script from any other binary, it makes sense that all configuration is lost. I would have loved to inherit the environment, so that I don't need to re-state it again.
```diff
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
environment: ${{ inputs.environment }}
packageManager: pnpm
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
preCommands: |
echo "Sync secrets to Cloudflare Workers Secrets"
- fetch_from_external_system | pnpm wrangler secret:bulk --env ${{ inputs.environment }}
+ fetch_from_external_system | wrangler secret:bulk
```
Let me know what you think about this. Definitely not urgent as there are easy workaround, but took me a couple attempts to get it right 😇
Thanks for all your work on the action 🙏
Contributor guide
Research direction
Start with the README's preCommands documentation and reproduce the reported pnpm wrangler secret:bulk workflow in a GitHub Actions job. Compare the documented behavior with direct command availability and configuration inheritance for preCommands. Done means the behavior is clarified or corrected and the README reflects how Wrangler commands and environment configuration work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100