mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2025-04-08 17:39:07 +02:00
Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
|
707f637509 | ||
|
e764ef3355 | ||
|
8d761e6bdc | ||
|
cd6314a97b | ||
|
ef1f9fb2b0 |
4 changed files with 101 additions and 3 deletions
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## 3.14.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#358](https://github.com/cloudflare/wrangler-action/pull/358) [`cd6314a`](https://github.com/cloudflare/wrangler-action/commit/cd6314a97b09d9a764e30cacd0870edc86f92986) Thanks [@penalosa](https://github.com/penalosa)! - Use `secret bulk` instead of deprecated `secret:bulk` command
|
||||
|
||||
## 3.14.0
|
||||
|
||||
### Minor Changes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wrangler-action",
|
||||
"version": "3.14.0",
|
||||
"version": "3.14.1",
|
||||
"description": "GitHub Action to use [Wrangler](https://developers.cloudflare.com/workers/cli-wrangler/).",
|
||||
"author": "wrangler@cloudflare.com",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { installWrangler } from "./wranglerAction";
|
||||
import { installWrangler, uploadSecrets } from "./wranglerAction";
|
||||
import { getTestConfig } from "./test/test-utils";
|
||||
|
||||
describe("installWrangler", () => {
|
||||
|
@ -76,3 +76,90 @@ describe("installWrangler", () => {
|
|||
expect(infoSpy).toBeCalledWith("✅ Wrangler installed");
|
||||
});
|
||||
});
|
||||
|
||||
describe("uploadSecrets", () => {
|
||||
const testPackageManager = {
|
||||
install: "npm i",
|
||||
exec: "npx",
|
||||
execNoInstall: "npx --no-install",
|
||||
};
|
||||
|
||||
it("WRANGLER_VERSION < 3.4.0 uses wrangler secret put", async () => {
|
||||
vi.stubEnv("FAKE_SECRET", "FAKE_VALUE");
|
||||
const testConfig = getTestConfig({
|
||||
config: {
|
||||
WRANGLER_VERSION: "3.3.0",
|
||||
didUserProvideWranglerVersion: true,
|
||||
secrets: ["FAKE_SECRET"],
|
||||
},
|
||||
});
|
||||
vi.spyOn(exec, "exec").mockImplementation(async (cmd, args) => {
|
||||
expect(cmd).toBe("npx");
|
||||
expect(args).toStrictEqual([
|
||||
"wrangler",
|
||||
"secret",
|
||||
"put",
|
||||
"FAKE_SECRET",
|
||||
"--env",
|
||||
"dev",
|
||||
]);
|
||||
return 0;
|
||||
});
|
||||
const startGroup = vi.spyOn(core, "startGroup");
|
||||
const endGroup = vi.spyOn(core, "endGroup");
|
||||
|
||||
await uploadSecrets(testConfig, testPackageManager);
|
||||
expect(startGroup).toBeCalledWith("🔑 Uploading secrets...");
|
||||
expect(endGroup).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("WRANGLER_VERSION < 3.60.0 uses wrangler secret:bulk", async () => {
|
||||
vi.stubEnv("FAKE_SECRET", "FAKE_VALUE");
|
||||
const testConfig = getTestConfig({
|
||||
config: {
|
||||
WRANGLER_VERSION: "3.59.0",
|
||||
didUserProvideWranglerVersion: true,
|
||||
secrets: ["FAKE_SECRET"],
|
||||
},
|
||||
});
|
||||
vi.spyOn(exec, "exec").mockImplementation(async (cmd, args) => {
|
||||
expect(cmd).toBe("npx");
|
||||
expect(args).toStrictEqual(["wrangler", "secret:bulk", "--env", "dev"]);
|
||||
return 0;
|
||||
});
|
||||
const startGroup = vi.spyOn(core, "startGroup");
|
||||
const endGroup = vi.spyOn(core, "endGroup");
|
||||
|
||||
await uploadSecrets(testConfig, testPackageManager);
|
||||
expect(startGroup).toBeCalledWith("🔑 Uploading secrets...");
|
||||
expect(endGroup).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("WRANGLER_VERSION 3.61.0 uses wrangler secret bulk", async () => {
|
||||
vi.stubEnv("FAKE_SECRET", "FAKE_VALUE");
|
||||
const testConfig = getTestConfig({
|
||||
config: {
|
||||
WRANGLER_VERSION: "3.61.0",
|
||||
didUserProvideWranglerVersion: true,
|
||||
secrets: ["FAKE_SECRET"],
|
||||
},
|
||||
});
|
||||
vi.spyOn(exec, "exec").mockImplementation(async (cmd, args) => {
|
||||
expect(cmd).toBe("npx");
|
||||
expect(args).toStrictEqual([
|
||||
"wrangler",
|
||||
"secret",
|
||||
"bulk",
|
||||
"--env",
|
||||
"dev",
|
||||
]);
|
||||
return 0;
|
||||
});
|
||||
const startGroup = vi.spyOn(core, "startGroup");
|
||||
const endGroup = vi.spyOn(core, "endGroup");
|
||||
|
||||
await uploadSecrets(testConfig, testPackageManager);
|
||||
expect(startGroup).toBeCalledWith("🔑 Uploading secrets...");
|
||||
expect(endGroup).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,6 +13,7 @@ import { exec, execShell } from "./exec";
|
|||
import { PackageManager } from "./packageManagers";
|
||||
import { error, info, semverCompare } from "./utils";
|
||||
import { handleCommandOutputParsing } from "./commandOutputParsing";
|
||||
import semverLt from "semver/functions/lt";
|
||||
|
||||
export type WranglerActionConfig = z.infer<typeof wranglerActionConfig>;
|
||||
export const wranglerActionConfig = z.object({
|
||||
|
@ -265,7 +266,11 @@ async function uploadSecrets(
|
|||
);
|
||||
}
|
||||
|
||||
const args = ["wrangler", "secret:bulk"];
|
||||
let args = ["wrangler", "secret", "bulk"];
|
||||
// if we're on a WRANGLER_VERSION prior to 3.60.0 use wrangler secret:bulk
|
||||
if (semverLt(config["WRANGLER_VERSION"], "3.60.0")) {
|
||||
args = ["wrangler", "secret:bulk"];
|
||||
}
|
||||
|
||||
if (environment) {
|
||||
args.push("--env", environment);
|
||||
|
|
Loading…
Add table
Reference in a new issue