Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3870f7e9d7 | |||
| 556068fb59 | |||
| caa59485d0 | |||
| c2494c1ca6 | |||
| 528687aaf4 | |||
| bd50d10af9 | |||
| 2513ffc6cc | |||
| 9df50d42e4 | |||
| 4611c14c05 | |||
| ac3f259fcf | |||
| b2645622e9 | |||
| f4e6269765 | |||
| 72931e59b2 | |||
| e0254d06bc | |||
| 13d70757d2 | |||
| aec73ae744 | |||
| f0cc3efccf | |||
| 50b529e7b8 | |||
| 6771675815 | |||
| 4ae0557f8d | |||
| 7d7b98826e | |||
| d1073d57ba | |||
| c3b99e2c18 | |||
| 2375787b23 | |||
| 11f981cea4 | |||
| 868dbd9a40 | |||
| a009342d77 | |||
| f2e4cda4dd | |||
| f4f2e854d7 | |||
| cbe5f5b523 | |||
| fcf2d83f3d | |||
| f5d1ca36ae | |||
| 4d6d6abfb4 |
+6
-1
@@ -4,7 +4,8 @@ branding:
|
||||
color: "orange"
|
||||
description: "Deploy your Cloudflare projects from GitHub using Wrangler"
|
||||
runs:
|
||||
using: "node16"
|
||||
# Possible values: https://github.com/actions/runner/blob/main/src/Runner.Common/Util/NodeUtil.cs#L9
|
||||
using: "node20"
|
||||
main: "dist/index.mjs"
|
||||
inputs:
|
||||
apiToken:
|
||||
@@ -40,3 +41,7 @@ inputs:
|
||||
vars:
|
||||
description: "A string of environment variable names, separated by newlines. These will be bound to your Worker using the values of matching environment variables declared in `env` of this workflow."
|
||||
required: false
|
||||
packageManager:
|
||||
description: "The package manager you'd like to use to install and run wrangler. If not specified, a value will be inferred based on the presence of a lockfile. Valid values: [npm, pnpm, yarn]"
|
||||
required: false
|
||||
default: npm
|
||||
|
||||
Vendored
+52
-10
@@ -2826,6 +2826,8 @@ __nccwpck_require__.d(__webpack_exports__, {
|
||||
var core = __nccwpck_require__(186);
|
||||
;// CONCATENATED MODULE: external "node:child_process"
|
||||
const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process");
|
||||
;// CONCATENATED MODULE: external "node:util"
|
||||
const external_node_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:util");
|
||||
;// CONCATENATED MODULE: external "node:fs"
|
||||
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
|
||||
;// CONCATENATED MODULE: external "node:path"
|
||||
@@ -2833,9 +2835,6 @@ const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(impo
|
||||
;// CONCATENATED MODULE: ./src/utils.ts
|
||||
|
||||
|
||||
function getNpxCmd() {
|
||||
return process.env.RUNNER_OS === "Windows" ? "npx.cmd" : "npx";
|
||||
}
|
||||
/**
|
||||
* A helper function to compare two semver versions. If the second arg is greater than the first arg, it returns true.
|
||||
*/
|
||||
@@ -2862,13 +2861,52 @@ function checkWorkingDirectory(workingDirectory = ".") {
|
||||
}
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external "node:util"
|
||||
const external_node_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:util");
|
||||
;// CONCATENATED MODULE: ./src/packageManagers.ts
|
||||
|
||||
|
||||
const PACKAGE_MANAGERS = {
|
||||
npm: {
|
||||
install: "npm i",
|
||||
exec: "npx",
|
||||
},
|
||||
yarn: {
|
||||
install: "yarn add",
|
||||
exec: "yarn",
|
||||
},
|
||||
pnpm: {
|
||||
install: "pnpm add",
|
||||
exec: "pnpm exec",
|
||||
},
|
||||
};
|
||||
function detectPackageManager(workingDirectory = ".") {
|
||||
if ((0,external_node_fs_namespaceObject.existsSync)(external_node_path_namespaceObject.join(workingDirectory, "package-lock.json"))) {
|
||||
return "npm";
|
||||
}
|
||||
if ((0,external_node_fs_namespaceObject.existsSync)(external_node_path_namespaceObject.join(workingDirectory, "yarn.lock"))) {
|
||||
return "yarn";
|
||||
}
|
||||
if ((0,external_node_fs_namespaceObject.existsSync)(external_node_path_namespaceObject.join(workingDirectory, "pnpm-lock.yaml"))) {
|
||||
return "pnpm";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function assertValidPackageManagerValue(name) {
|
||||
if (name && !Object.keys(PACKAGE_MANAGERS).includes(name)) {
|
||||
throw new TypeError(`invalid value provided for "packageManager": ${name}
|
||||
Value must be one of: [${Object.keys(PACKAGE_MANAGERS).join(", ")}]`);
|
||||
}
|
||||
}
|
||||
function getPackageManager(name, { workingDirectory = "." } = {}) {
|
||||
assertValidPackageManagerValue(name);
|
||||
return PACKAGE_MANAGERS[name || detectPackageManager(workingDirectory) || "npm"];
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/index.ts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const execAsync = external_node_util_namespaceObject.promisify(external_node_child_process_namespaceObject.exec);
|
||||
const DEFAULT_WRANGLER_VERSION = "3.5.1";
|
||||
/**
|
||||
@@ -2884,7 +2922,11 @@ const config = {
|
||||
VARS: (0,core.getMultilineInput)("vars"),
|
||||
COMMANDS: (0,core.getMultilineInput)("command"),
|
||||
QUIET_MODE: (0,core.getBooleanInput)("quiet"),
|
||||
PACKAGE_MANAGER: (0,core.getInput)("packageManager"),
|
||||
};
|
||||
const packageManager = getPackageManager(config.PACKAGE_MANAGER, {
|
||||
workingDirectory: config.workingDirectory,
|
||||
});
|
||||
function info(message, bypass) {
|
||||
if (!config.QUIET_MODE || bypass) {
|
||||
(0,core.info)(message);
|
||||
@@ -2938,7 +2980,7 @@ function installWrangler() {
|
||||
throw new Error(`Wrangler v1 is no longer supported by this action. Please use major version 2 or greater`);
|
||||
}
|
||||
startGroup("📥 Installing Wrangler");
|
||||
const command = `npm install wrangler@${config["WRANGLER_VERSION"]}`;
|
||||
const command = `${packageManager.install} wrangler@${config["WRANGLER_VERSION"]}`;
|
||||
info(`Running command: ${command}`);
|
||||
(0,external_node_child_process_namespaceObject.execSync)(command, { cwd: config["workingDirectory"], env: process.env });
|
||||
info(`✅ Wrangler installed`, true);
|
||||
@@ -2956,7 +2998,7 @@ async function execCommands(commands, cmdType) {
|
||||
try {
|
||||
const arrPromises = commands.map(async (command) => {
|
||||
const cmd = command.startsWith("wrangler")
|
||||
? `${getNpxCmd()} ${command}`
|
||||
? `${packageManager.exec} ${command}`
|
||||
: command;
|
||||
info(`🚀 Executing command: ${cmd}`);
|
||||
return await runProcess(cmd, {
|
||||
@@ -2986,7 +3028,7 @@ function getSecret(secret) {
|
||||
async function legacyUploadSecrets(secrets, environment, workingDirectory) {
|
||||
const arrPromises = secrets
|
||||
.map((secret) => {
|
||||
const command = `echo ${getSecret(secret)} | ${getNpxCmd()} wrangler secret put ${secret}`;
|
||||
const command = `echo ${getSecret(secret)} | ${packageManager.exec} wrangler secret put ${secret}`;
|
||||
return environment ? command.concat(` --env ${environment}`) : command;
|
||||
})
|
||||
.map(async (command) => await execAsync(command, {
|
||||
@@ -3013,7 +3055,7 @@ async function uploadSecrets() {
|
||||
const environmentSuffix = !environment.length
|
||||
? ""
|
||||
: ` --env ${environment}`;
|
||||
const secretCmd = `echo "${JSON.stringify(secretObj).replaceAll('"', '\\"')}" | ${getNpxCmd()} wrangler secret:bulk ${environmentSuffix}`;
|
||||
const secretCmd = `echo "${JSON.stringify(secretObj).replaceAll('"', '\\"')}" | ${packageManager.exec} wrangler secret:bulk ${environmentSuffix}`;
|
||||
(0,external_node_child_process_namespaceObject.execSync)(secretCmd, {
|
||||
cwd: workingDirectory,
|
||||
env: process.env,
|
||||
@@ -3057,7 +3099,7 @@ async function wranglerCommands() {
|
||||
if (environment.length > 0 && !command.includes(`--env`)) {
|
||||
command = command.concat(` --env ${environment}`);
|
||||
}
|
||||
const cmd = `${getNpxCmd()} wrangler ${command} ${(command.startsWith("deploy") || command.startsWith("publish")) &&
|
||||
const cmd = `${packageManager.exec} wrangler ${command} ${(command.startsWith("deploy") || command.startsWith("publish")) &&
|
||||
!command.includes(`--var`)
|
||||
? getVarArgs()
|
||||
: ""}`.trim();
|
||||
|
||||
Reference in New Issue
Block a user