mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-21 17:43:23 +01:00
fix: Use wrangler secret put instead of deprecated secret:bulk command
`wrangler secret:bulk` is deprecated and will be removed in a future version. This also improves logging in cases where a secret is failing to upload because an environment variable with the same name already exists (see: #240).
This commit is contained in:
parent
ac2fd0ec8f
commit
0ca18d5d22
3 changed files with 2031 additions and 46 deletions
7
.changeset/odd-oranges-breathe.md
Normal file
7
.changeset/odd-oranges-breathe.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
"wrangler-action": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Use wrangler secret put instead of deprecated secret:bulk command
|
||||||
|
|
||||||
|
`wrangler secret:bulk` is deprecated and will be removed in a future version. This also improves logging in cases where a secret is failing to upload because an environment variable with the same name already exists (see: #240).
|
2013
pnpm-lock.yaml
Normal file
2013
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -241,26 +241,6 @@ function getEnvVar(envVar: string) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function legacyUploadSecrets(
|
|
||||||
config: WranglerActionConfig,
|
|
||||||
packageManager: PackageManager,
|
|
||||||
secrets: string[],
|
|
||||||
environment?: string,
|
|
||||||
workingDirectory?: string,
|
|
||||||
) {
|
|
||||||
for (const secret of secrets) {
|
|
||||||
const args = ["wrangler", "secret", "put", secret];
|
|
||||||
if (environment) {
|
|
||||||
args.push("--env", environment);
|
|
||||||
}
|
|
||||||
await exec(packageManager.exec, args, {
|
|
||||||
cwd: workingDirectory,
|
|
||||||
silent: config["QUIET_MODE"],
|
|
||||||
input: Buffer.from(getSecret(secret)),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function uploadSecrets(
|
async function uploadSecrets(
|
||||||
config: WranglerActionConfig,
|
config: WranglerActionConfig,
|
||||||
packageManager: PackageManager,
|
packageManager: PackageManager,
|
||||||
|
@ -276,18 +256,8 @@ async function uploadSecrets(
|
||||||
startGroup(config, "🔑 Uploading secrets...");
|
startGroup(config, "🔑 Uploading secrets...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (semverCompare(config["WRANGLER_VERSION"], "3.4.0")) {
|
for (const secret of secrets) {
|
||||||
return legacyUploadSecrets(
|
const args = ["wrangler", "secret", "put", secret];
|
||||||
config,
|
|
||||||
packageManager,
|
|
||||||
secrets,
|
|
||||||
environment,
|
|
||||||
workingDirectory,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const args = ["wrangler", "secret:bulk"];
|
|
||||||
|
|
||||||
if (environment) {
|
if (environment) {
|
||||||
args.push("--env", environment);
|
args.push("--env", environment);
|
||||||
}
|
}
|
||||||
|
@ -295,14 +265,9 @@ async function uploadSecrets(
|
||||||
await exec(packageManager.exec, args, {
|
await exec(packageManager.exec, args, {
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
silent: config["QUIET_MODE"],
|
silent: config["QUIET_MODE"],
|
||||||
input: Buffer.from(
|
input: Buffer.from(getSecret(secret)),
|
||||||
JSON.stringify(
|
|
||||||
Object.fromEntries(
|
|
||||||
secrets.map((secret) => [secret, getSecret(secret)]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
error(config, err.message);
|
error(config, err.message);
|
||||||
|
|
Loading…
Reference in a new issue