Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 80501a7b4d | |||
| 3252711404 | |||
| 2faabf36a2 | |||
| b734d85d74 | |||
| 8ca2ff1612 | |||
| 7d08a8657e | |||
| e193627f19 | |||
| 55b80c5f62 | |||
| f61dc4d5a9 | |||
| 58f274b9f7 | |||
| ef7686b259 | |||
| d63b9dc486 | |||
| 88ccce72e0 | |||
| 554eea134a | |||
| a584cc5606 | |||
| 0f5076c3e7 | |||
| c7d1bd35bf | |||
| 3c728e1d5d | |||
| a333df3c9e | |||
| bb0133dcfc | |||
| 88466ea5ae | |||
| 74433eb31e | |||
| 559dd40fe6 | |||
| 9930080b73 | |||
| 43bbbb16ab | |||
| 598c6b4043 | |||
| 0c094f5307 | |||
| 6ea2e616f2 | |||
| 1b4a61cee9 | |||
| 8e3876a0c9 | |||
| 8fab856f8d | |||
| ce1ea4e7c3 | |||
| 311d514d9d |
Vendored
+42
-34
@@ -2878,10 +2878,23 @@ function semverCompare(version1, version2) {
|
||||
async function main() {
|
||||
installWrangler();
|
||||
authenticationSetup();
|
||||
await execCommands((0,core.getMultilineInput)("preCommands"), "Pre");
|
||||
await execCommands((0,core.getMultilineInput)("preCommands"), "pre");
|
||||
await uploadSecrets();
|
||||
await wranglerCommands();
|
||||
await execCommands((0,core.getMultilineInput)("postCommands"), "Post");
|
||||
await execCommands((0,core.getMultilineInput)("postCommands"), "post");
|
||||
}
|
||||
async function runProcess(command, options) {
|
||||
try {
|
||||
const result = await execAsync(command, options);
|
||||
result.stdout && (0,core.info)(result.stdout.toString());
|
||||
result.stderr && (0,core.error)(result.stderr.toString());
|
||||
return result;
|
||||
}
|
||||
catch (err) {
|
||||
err.stdout && (0,core.info)(err.stdout.toString());
|
||||
err.stderr && (0,core.error)(err.stderr.toString());
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
function checkWorkingDirectory(workingDirectory = ".") {
|
||||
try {
|
||||
@@ -2916,18 +2929,22 @@ async function execCommands(commands, cmdType) {
|
||||
if (!commands.length) {
|
||||
return;
|
||||
}
|
||||
(0,core.startGroup)(`🚀 ${cmdType} Commands Group`);
|
||||
(0,core.startGroup)(`🚀 Running ${cmdType}Commands`);
|
||||
const arrPromises = commands.map(async (command) => {
|
||||
const cmd = command.startsWith("wrangler")
|
||||
? `${getNpxCmd()} ${command}`
|
||||
: command;
|
||||
(0,core.info)(`🚀 Executing command: ${cmd}`);
|
||||
return await execAsync(cmd, {
|
||||
return await runProcess(cmd, {
|
||||
cwd: config["workingDirectory"],
|
||||
env: process.env,
|
||||
});
|
||||
});
|
||||
await Promise.all(arrPromises);
|
||||
await Promise.all(arrPromises).catch((result) => {
|
||||
result.stdout && (0,core.info)(result.stdout.toString());
|
||||
result.stderr && (0,core.error)(result.stderr.toString());
|
||||
(0,core.setFailed)(`🚨 ${cmdType}Commands failed`);
|
||||
});
|
||||
(0,core.endGroup)();
|
||||
}
|
||||
/**
|
||||
@@ -2948,7 +2965,7 @@ async function legacyUploadSecrets(secrets, environment, workingDirectory) {
|
||||
const arrPromises = secrets
|
||||
.map((secret) => {
|
||||
const command = `echo ${getSecret(secret)} | ${getNpxCmd()} wrangler secret put ${secret}`;
|
||||
return environment ? command.concat(`--env ${environment}`) : command;
|
||||
return environment ? command.concat(` --env ${environment}`) : command;
|
||||
})
|
||||
.map(async (command) => await execAsync(command, {
|
||||
cwd: workingDirectory,
|
||||
@@ -3005,45 +3022,36 @@ function getVarArgs() {
|
||||
});
|
||||
return envVarArray.length > 0 ? `--var ${envVarArray.join(" ").trim()}` : "";
|
||||
}
|
||||
function defaultCommandBehavior() {
|
||||
const environment = config["ENVIRONMENT"];
|
||||
const wranglerVersion = config["WRANGLER_VERSION"];
|
||||
const workingDirectory = config["workingDirectory"];
|
||||
const deployCommand = semverCompare("2.20.0", wranglerVersion)
|
||||
? "deploy"
|
||||
: "publish";
|
||||
(0,core.info)(`📌 No Wrangler commands were provided, executing default deployment.`);
|
||||
if (environment.length === 0) {
|
||||
(0,external_node_child_process_namespaceObject.execSync)(`${getNpxCmd()} wrangler ${deployCommand} ${getVarArgs()}`.trim(), {
|
||||
cwd: workingDirectory,
|
||||
env: process.env,
|
||||
});
|
||||
}
|
||||
else {
|
||||
(0,external_node_child_process_namespaceObject.execSync)(`${getNpxCmd()} wrangler ${deployCommand} --env ${environment} ${getVarArgs()}`.trim(), { cwd: workingDirectory, env: process.env });
|
||||
}
|
||||
(0,core.endGroup)();
|
||||
}
|
||||
async function wranglerCommands() {
|
||||
(0,core.startGroup)("🚀 Running Wrangler Commands");
|
||||
const commands = config["COMMANDS"];
|
||||
const environment = config["ENVIRONMENT"];
|
||||
if (!commands.length) {
|
||||
defaultCommandBehavior();
|
||||
return;
|
||||
const wranglerVersion = config["WRANGLER_VERSION"];
|
||||
const deployCommand = semverCompare("2.20.0", wranglerVersion)
|
||||
? "deploy"
|
||||
: "publish";
|
||||
commands.push(deployCommand);
|
||||
}
|
||||
(0,core.startGroup)("🚀 Executing Wrangler Commands");
|
||||
const arrPromises = commands.map(async (command) => {
|
||||
if (environment.length > 0 && !command.includes(`--env ${environment}`)) {
|
||||
command.concat(`--env ${environment}`);
|
||||
if (environment.length > 0 && !command.includes(`--env`)) {
|
||||
command = command.concat(` --env ${environment}`);
|
||||
}
|
||||
const result = await execAsync(`${getNpxCmd()} wrangler ${command} ${getVarArgs()}`, {
|
||||
const cmd = `${getNpxCmd()} wrangler ${command} ${(command.startsWith("deploy") || command.startsWith("publish")) &&
|
||||
!command.includes(`--var`)
|
||||
? getVarArgs()
|
||||
: ""}`.trim();
|
||||
(0,core.info)(`🚀 Executing command: ${cmd}`);
|
||||
return await runProcess(cmd, {
|
||||
cwd: config["workingDirectory"],
|
||||
env: process.env,
|
||||
});
|
||||
(0,core.info)(result.stdout);
|
||||
return result;
|
||||
});
|
||||
await Promise.all(arrPromises);
|
||||
await Promise.all(arrPromises).catch((result) => {
|
||||
result.stdout && (0,core.info)(result.stdout.toString());
|
||||
result.stderr && (0,core.error)(result.stderr.toString());
|
||||
(0,core.setFailed)(`🚨 Command failed`);
|
||||
});
|
||||
(0,core.endGroup)();
|
||||
}
|
||||
main().catch(() => (0,core.setFailed)("🚨 Action failed"));
|
||||
|
||||
Reference in New Issue
Block a user