Skip to content

Commit 4a16924

Browse files
docs: add --secrets-file documentation for wrangler deploy and versions upload (#28976)
1 parent 1fc786b commit 4a16924

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/content/docs/workers/configuration/secrets.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ To add a secret via the dashboard:
113113
5. (Optional) To add more secrets, select **Add variable**.
114114
6. Select **Deploy** to implement your changes.
115115

116+
#### Upload secrets alongside code
117+
118+
You can upload secrets at the same time as your Worker code using the `--secrets-file` flag on [`wrangler deploy`](/workers/wrangler/commands/workers/#deploy) or [`wrangler versions upload`](/workers/wrangler/commands/workers/#versions-upload). This accepts a path to a JSON or `.env` file — the same formats accepted by [`wrangler secret bulk`](/workers/wrangler/commands/workers/#secret-bulk).
119+
120+
```sh
121+
npx wrangler deploy --secrets-file .env.production
122+
```
123+
124+
```sh
125+
npx wrangler versions upload --secrets-file secrets.json
126+
```
127+
128+
Secrets not included in the file are preserved from the previous version. This is useful in CI/CD pipelines where you want to deploy code and update secrets in a single operation.
129+
116130
### Delete secrets from your project
117131

118132
#### Via Wrangler

src/content/docs/workers/wrangler/commands/workers.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ None of the options for this command are required. Also, many can be set in your
221221
- It is recommended best practice to treat your Wrangler developer environment as a source of truth for your Worker configuration, and avoid making changes via the Cloudflare dashboard.
222222
- If you change your environment variables in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behaviour set `keep-vars` to `true`.
223223
- Secrets are never deleted by a deployment whether this flag is true or false.
224+
- `--secrets-file` <Type text="string" /> <MetaInfo text="optional" />
225+
- Path to a file containing secrets to upload alongside the deployment. Accepts JSON or `.env` format — the same formats used by [`wrangler secret bulk`](#secret-bulk). Existing secrets not included in the file are preserved from the previous version. Refer to [Secrets — Upload secrets alongside code](/workers/configuration/secrets/#upload-secrets-alongside-code) for more details.
224226
- `--dispatch-namespace` <Type text="string" /> <MetaInfo text="optional" />
225227
- Specify the [Workers for Platforms dispatch namespace](/cloudflare-for-platforms/workers-for-platforms/how-workers-for-platforms-works/#dispatch-namespace) to upload this Worker to.
226228
- `--metafile` <Type text="string" /> <MetaInfo text="optional" />

0 commit comments

Comments
 (0)