mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-24 02:44:45 +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;
|
||||
}
|
||||
|
||||
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(
|
||||
config: WranglerActionConfig,
|
||||
packageManager: PackageManager,
|
||||
|
@ -276,33 +256,18 @@ async function uploadSecrets(
|
|||
startGroup(config, "🔑 Uploading secrets...");
|
||||
|
||||
try {
|
||||
if (semverCompare(config["WRANGLER_VERSION"], "3.4.0")) {
|
||||
return legacyUploadSecrets(
|
||||
config,
|
||||
packageManager,
|
||||
secrets,
|
||||
environment,
|
||||
workingDirectory,
|
||||
);
|
||||
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)),
|
||||
});
|
||||
}
|
||||
|
||||
const args = ["wrangler", "secret:bulk"];
|
||||
|
||||
if (environment) {
|
||||
args.push("--env", environment);
|
||||
}
|
||||
|
||||
await exec(packageManager.exec, args, {
|
||||
cwd: workingDirectory,
|
||||
silent: config["QUIET_MODE"],
|
||||
input: Buffer.from(
|
||||
JSON.stringify(
|
||||
Object.fromEntries(
|
||||
secrets.map((secret) => [secret, getSecret(secret)]),
|
||||
),
|
||||
),
|
||||
),
|
||||
});
|
||||
} catch (err: unknown) {
|
||||
if (err instanceof Error) {
|
||||
error(config, err.message);
|
||||
|
|
Loading…
Reference in a new issue