Compare commits

..

1 Commits

Author SHA1 Message Date
github-actions[bot] 80501a7b4d Automatic compilation 2023-08-10 22:05:35 +00:00
2 changed files with 23 additions and 48 deletions
+1 -4
View File
@@ -13,10 +13,7 @@ inputs:
accountId:
description: "Your Cloudflare Account ID"
required: false
quiet:
description: "Supresses output from Wrangler commands, defaults to `false`"
required: false
default: "false"
environment:
description: "The environment you'd like to deploy your Workers project to - must be defined in wrangler.toml"
workingDirectory:
+22 -44
View File
@@ -2842,7 +2842,7 @@ const external_node_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(impo
const execAsync = external_node_util_namespaceObject.promisify(external_node_child_process_namespaceObject.exec);
const DEFAULT_WRANGLER_VERSION = "3.5.1";
const DEFAULT_WRANGLER_VERSION = "3.4.0";
/**
* A configuration object that contains all the inputs & immutable state for the action.
*/
@@ -2855,31 +2855,10 @@ const config = {
ENVIRONMENT: (0,core.getInput)("environment"),
VARS: (0,core.getMultilineInput)("vars"),
COMMANDS: (0,core.getMultilineInput)("command"),
QUIET_MODE: (0,core.getBooleanInput)("quiet"),
};
function getNpxCmd() {
return process.env.RUNNER_OS === "Windows" ? "npx.cmd" : "npx";
}
function info(message, bypass) {
if (!config.QUIET_MODE || bypass) {
(0,core.info)(message);
}
}
function error(message, bypass) {
if (!config.QUIET_MODE || bypass) {
(0,core.error)(message);
}
}
function startGroup(name) {
if (!config.QUIET_MODE) {
(0,core.startGroup)(name);
}
}
function endGroup() {
if (!config.QUIET_MODE) {
(0,core.endGroup)();
}
}
/**
* A helper function to compare two semver versions. If the second arg is greater than the first arg, it returns true.
*/
@@ -2903,18 +2882,17 @@ async function main() {
await uploadSecrets();
await wranglerCommands();
await execCommands((0,core.getMultilineInput)("postCommands"), "post");
info("🏁 Wrangler Action completed", true);
}
async function runProcess(command, options) {
try {
const result = await execAsync(command, options);
result.stdout && info(result.stdout.toString());
result.stderr && error(result.stderr.toString(), true);
result.stdout && (0,core.info)(result.stdout.toString());
result.stderr && (0,core.error)(result.stderr.toString());
return result;
}
catch (err) {
err.stdout && info(err.stdout.toString());
err.stderr && error(err.stderr.toString(), true);
err.stdout && (0,core.info)(err.stdout.toString());
err.stderr && (0,core.error)(err.stderr.toString());
throw err;
}
}
@@ -2936,12 +2914,12 @@ function installWrangler() {
if (config["WRANGLER_VERSION"].startsWith("1")) {
(0,core.setFailed)(`🚨 Wrangler v1 is no longer supported by this action. Please use major version 2 or greater`);
}
startGroup("📥 Installing Wrangler");
(0,core.startGroup)("📥 Installing Wrangler");
const command = `npm install wrangler@${config["WRANGLER_VERSION"]}`;
info(`Running command: ${command}`);
(0,core.info)(`Running command: ${command}`);
(0,external_node_child_process_namespaceObject.execSync)(command, { cwd: config["workingDirectory"], env: process.env });
info(`✅ Wrangler installed`, true);
endGroup();
(0,core.info)(`✅ Wrangler installed`);
(0,core.endGroup)();
}
function authenticationSetup() {
process.env.CLOUDFLARE_API_TOKEN = config["CLOUDFLARE_API_TOKEN"];
@@ -2951,23 +2929,23 @@ async function execCommands(commands, cmdType) {
if (!commands.length) {
return;
}
startGroup(`🚀 Running ${cmdType}Commands`);
(0,core.startGroup)(`🚀 Running ${cmdType}Commands`);
const arrPromises = commands.map(async (command) => {
const cmd = command.startsWith("wrangler")
? `${getNpxCmd()} ${command}`
: command;
info(`🚀 Executing command: ${cmd}`);
(0,core.info)(`🚀 Executing command: ${cmd}`);
return await runProcess(cmd, {
cwd: config["workingDirectory"],
env: process.env,
});
});
await Promise.all(arrPromises).catch((result) => {
result.stdout && info(result.stdout.toString());
result.stderr && error(result.stderr.toString(), true);
result.stdout && (0,core.info)(result.stdout.toString());
result.stderr && (0,core.error)(result.stderr.toString());
(0,core.setFailed)(`🚨 ${cmdType}Commands failed`);
});
endGroup();
(0,core.endGroup)();
}
/**
* A helper function to get the secret from the environment variables.
@@ -3007,7 +2985,7 @@ async function uploadSecrets() {
return;
}
try {
startGroup("🔑 Uploading Secrets");
(0,core.startGroup)("🔑 Uploading Secrets");
if (semverCompare(config["WRANGLER_VERSION"], "3.4.0"))
return legacyUploadSecrets(secrets, environment, workingDirectory);
const secretObj = secrets.reduce((acc, secret) => {
@@ -3023,13 +3001,13 @@ async function uploadSecrets() {
env: process.env,
stdio: "ignore",
});
info(`✅ Uploaded secrets`);
(0,core.info)(`✅ Uploaded secrets`);
}
catch {
(0,core.setFailed)(`🚨 Error uploading secrets`);
}
finally {
endGroup();
(0,core.endGroup)();
}
}
function getVarArgs() {
@@ -3045,7 +3023,7 @@ function getVarArgs() {
return envVarArray.length > 0 ? `--var ${envVarArray.join(" ").trim()}` : "";
}
async function wranglerCommands() {
startGroup("🚀 Running Wrangler Commands");
(0,core.startGroup)("🚀 Running Wrangler Commands");
const commands = config["COMMANDS"];
const environment = config["ENVIRONMENT"];
if (!commands.length) {
@@ -3063,18 +3041,18 @@ async function wranglerCommands() {
!command.includes(`--var`)
? getVarArgs()
: ""}`.trim();
info(`🚀 Executing command: ${cmd}`);
(0,core.info)(`🚀 Executing command: ${cmd}`);
return await runProcess(cmd, {
cwd: config["workingDirectory"],
env: process.env,
});
});
await Promise.all(arrPromises).catch((result) => {
result.stdout && info(result.stdout.toString());
result.stderr && error(result.stderr.toString());
result.stdout && (0,core.info)(result.stdout.toString());
result.stderr && (0,core.error)(result.stderr.toString());
(0,core.setFailed)(`🚨 Command failed`);
});
endGroup();
(0,core.endGroup)();
}
main().catch(() => (0,core.setFailed)("🚨 Action failed"));