Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -65,6 +65,55 @@ async function trigger(resourceUuid) {
|
||||
process.stdout.write(uuid);
|
||||
}
|
||||
|
||||
function envKey(entry) {
|
||||
return typeof entry?.key === "string" ? entry.key : "";
|
||||
}
|
||||
|
||||
function envValue(entry) {
|
||||
const value = entry?.value ?? entry?.real_value;
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
async function setEnvs(resourceUuid, pairs) {
|
||||
if (!resourceUuid) {
|
||||
fail("Coolify resource UUID is required");
|
||||
}
|
||||
if (pairs.length === 0) {
|
||||
fail("At least one KEY=VALUE pair is required");
|
||||
}
|
||||
const parsed = pairs.map((pair) => {
|
||||
const separator = pair.indexOf("=");
|
||||
if (separator <= 0) {
|
||||
fail(`Invalid KEY=VALUE pair: ${pair}`);
|
||||
}
|
||||
return [pair.slice(0, separator), pair.slice(separator + 1)];
|
||||
});
|
||||
|
||||
const existingPayload = await coolify(`/applications/${encodeURIComponent(resourceUuid)}/envs`);
|
||||
const existing = Array.isArray(existingPayload) ? existingPayload : Array.isArray(existingPayload?.data) ? existingPayload.data : [];
|
||||
const byKey = new Map(existing.map((entry) => [envKey(entry), entry]).filter(([key]) => key));
|
||||
|
||||
for (const [key, value] of parsed) {
|
||||
const current = byKey.get(key);
|
||||
if (current && envValue(current) === value) {
|
||||
process.stdout.write(`env ${key} unchanged\n`);
|
||||
continue;
|
||||
}
|
||||
await coolify(`/applications/${encodeURIComponent(resourceUuid)}/envs`, {
|
||||
method: current ? "PATCH" : "POST",
|
||||
body: JSON.stringify({
|
||||
key,
|
||||
value,
|
||||
is_literal: true,
|
||||
is_preview: false,
|
||||
is_multiline: false,
|
||||
is_shown_once: false,
|
||||
}),
|
||||
});
|
||||
process.stdout.write(`env ${key} ${current ? "updated" : "created"}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
async function waitForDeployment(uuid, label) {
|
||||
if (!uuid) {
|
||||
fail("Coolify deployment UUID is required");
|
||||
@@ -88,6 +137,8 @@ if (command === "trigger") {
|
||||
await trigger(args[0] || "");
|
||||
} else if (command === "wait") {
|
||||
await waitForDeployment(args[0] || "", args[1] || "Coolify");
|
||||
} else if (command === "set-envs") {
|
||||
await setEnvs(args[0] || "", args.slice(1));
|
||||
} else {
|
||||
fail("Usage: coolify-deploy.mjs trigger <resource-uuid> | wait <deployment-uuid> <label>");
|
||||
fail("Usage: coolify-deploy.mjs trigger <resource-uuid> | wait <deployment-uuid> <label> | set-envs <resource-uuid> KEY=VALUE...");
|
||||
}
|
||||
Reference in new issue
Block a user