Skip to main content

Procedures and Actions

Komodo offers Procedure and Action resources for orchestrating multi-resource workflows. Both can be run on a schedule

Procedures

A Procedure composes multiple executions (like RunBuild, DeployStack, Deploy) into a series of Stages. Executions within a stage run in parallel; stages run sequentially. The Procedure waits for all executions in a stage to complete before moving to the next.

[[procedure]]
name = "build-and-deploy"
description = "Builds the app, then deploys both instances"

[[procedure.config.stage]]
name = "Build"
executions = [
{ execution.type = "RunBuild", execution.params.build = "my-app" },
]

[[procedure.config.stage]]
name = "Deploy"
executions = [
{ execution.type = "Deploy", execution.params.deployment = "my-app-01" },
{ execution.type = "Deploy", execution.params.deployment = "my-app-02" },
]

Config fields

FieldDescriptionDefault
config.stage[].nameDisplay name for the stage.
config.stage[].enabledWhether the stage is active.true
config.stage[].executionsList of executions to run in parallel within the stage.[]
scheduleSchedule expression. See Schedules.""
schedule_formatEnglish or Cron.English
schedule_enabledWhether the schedule is active.true

Batch Executions

Many executions have a Batch variant (e.g. BatchDeployStackIfChanged) that matches multiple resources by name using wildcard and regex syntax.

[[procedure.config.stage]]
name = "Deploy matching stacks"
executions = [
{ execution.type = "BatchDeployStackIfChanged", execution.params.pattern = "foo-* , \\^bar-.*$\\" },
]

Actions

Actions let you write Typescript scripts that call the Komodo API. A pre-initialized komodo client is available — no API key configuration needed. The in UI editor provides type-aware suggestions and inline documentation.

const VERSION = "1.16.5";
const BRANCH = "dev/" + VERSION;
const APPS = ["core", "periphery"];
const ARCHS = ["x86", "aarch64"];

await komodo.write("UpdateVariableValue", {
name: "KOMODO_DEV_VERSION",
value: VERSION,
});

for (const app of APPS) {
for (const arch of ARCHS) {
const name = `komodo-${app}-${arch}-dev`;
await komodo.write("UpdateBuild", {
id: name,
config: { version: VERSION as any, branch: BRANCH },
});
console.log(`Updated Build ${name}`);
}
}

The Typescript client is also published on NPM.

Action examples

Restart all deployments matching tags

const deployments = await komodo.read("ListDeployments", {
query: { tags: ["backend"] },
});

for (const deployment of deployments) {
await komodo.execute("RestartDeployment", {
deployment: deployment.name,
});
console.log(`Restarted ${deployment.name}`);
}

Run a command on a server terminal

await komodo.execute_server_terminal({
server: "server-prod",
command: "df -h",
init: { command: "bash" },
}, {
onLine: (line) => console.log(line),
onFinish: (code) => console.log("Exit code:", code),
});

Scale a deployment based on time of day

const hour = new Date().getHours();
const replicas = hour >= 9 && hour <= 17 ? "4" : "1";

await komodo.write("UpdateDeployment", {
id: "api-server",
config: {
extra_args: [`--replicas=${replicas}`],
},
});

await komodo.execute("Deploy", { deployment: "api-server" });
console.log(`Scaled api-server to ${replicas} replicas`);