mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 06:56:44 +00:00
Aplicou deploy from source
X-Lovable-Edit-ID: edt-c10eea25-1ec4-4454-9999-027ae742327c Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
commit
6d02fb8241
3 changed files with 11 additions and 5 deletions
|
|
@ -130,14 +130,16 @@ export async function configureRailwayService(opts: {
|
||||||
|
|
||||||
export async function deployRailwayService(opts: {
|
export async function deployRailwayService(opts: {
|
||||||
token: string;
|
token: string;
|
||||||
serviceId: string;
|
|
||||||
environmentId: string;
|
environmentId: string;
|
||||||
/** Use true on the first deploy of a freshly-created service (no prior deployment exists). */
|
/** Use true on the first deploy of a freshly-created service (no prior deployment exists). */
|
||||||
firstDeploy?: boolean;
|
firstDeploy?: boolean;
|
||||||
|
/** Use true after changing the configured source image so Railway pulls the current source. */
|
||||||
|
fromSource?: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
// serviceInstanceRedeploy só funciona se já existe um deployment.
|
// serviceInstanceRedeploy só funciona se já existe um deployment.
|
||||||
// Para o primeiro deploy de um serviço recém-criado, usamos serviceInstanceDeployV2.
|
// Para o primeiro deploy de um serviço recém-criado, ou após trocar source.image,
|
||||||
if (opts.firstDeploy) {
|
// usamos DeployV2 para puxar a fonte/imagem configurada em vez de reusar o último deploy.
|
||||||
|
if (opts.firstDeploy || opts.fromSource) {
|
||||||
const mutation = `
|
const mutation = `
|
||||||
mutation ServiceInstanceDeployV2($serviceId: String!, $environmentId: String!) {
|
mutation ServiceInstanceDeployV2($serviceId: String!, $environmentId: String!) {
|
||||||
serviceInstanceDeployV2(serviceId: $serviceId, environmentId: $environmentId)
|
serviceInstanceDeployV2(serviceId: $serviceId, environmentId: $environmentId)
|
||||||
|
|
@ -169,10 +171,11 @@ export async function deployRailwayService(opts: {
|
||||||
// Fallback: serviço novo sem deploy anterior — redeploy falha, tenta V2.
|
// Fallback: serviço novo sem deploy anterior — redeploy falha, tenta V2.
|
||||||
if (errStr.includes("no deployment") || errStr.includes("No deployments") || errStr.includes("not found")) {
|
if (errStr.includes("no deployment") || errStr.includes("No deployments") || errStr.includes("not found")) {
|
||||||
console.warn(`[deployRailwayService] redeploy sem deploy anterior, fallback para serviceInstanceDeployV2`);
|
console.warn(`[deployRailwayService] redeploy sem deploy anterior, fallback para serviceInstanceDeployV2`);
|
||||||
await deployRailwayService({ ...opts, firstDeploy: true });
|
await deployRailwayService({ ...opts, firstDeploy: true, fromSource: false });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new Error(`serviceInstanceRedeploy failed: ${errStr}`);
|
throw new Error(`serviceInstanceRedeploy failed: ${errStr}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,11 +181,12 @@ Deno.serve(async (req) => {
|
||||||
startCommand: HERMES_START_COMMAND,
|
startCommand: HERMES_START_COMMAND,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3) redeploy
|
// 3) deploy from source para puxar a imagem reconciliada, não o último deploy antigo
|
||||||
await deployRailwayService({
|
await deployRailwayService({
|
||||||
token: RAILWAY_API_TOKEN,
|
token: RAILWAY_API_TOKEN,
|
||||||
serviceId: agent.railway_service_id as string,
|
serviceId: agent.railway_service_id as string,
|
||||||
environmentId,
|
environmentId,
|
||||||
|
fromSource: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
entry.status = "ok";
|
entry.status = "ok";
|
||||||
|
|
|
||||||
|
|
@ -641,7 +641,9 @@ async function handleUpdateExistingService(
|
||||||
token: RAILWAY_API_TOKEN!,
|
token: RAILWAY_API_TOKEN!,
|
||||||
serviceId: railwayServiceId,
|
serviceId: railwayServiceId,
|
||||||
environmentId,
|
environmentId,
|
||||||
|
fromSource: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`[provision-agent:update] redeploy disparado`);
|
console.log(`[provision-agent:update] redeploy disparado`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const msg = e instanceof Error ? e.message : String(e);
|
const msg = e instanceof Error ? e.message : String(e);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue