Skip to content

Commit 965cd22

Browse files
committed
Enable setting the initial status on deployment creation
1 parent 9c08764 commit 965cd22

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

apps/webapp/app/routes/api.v1.deployments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { ActionFunctionArgs, json } from "@remix-run/server-runtime";
1+
import { type ActionFunctionArgs, json } from "@remix-run/server-runtime";
22
import {
33
ApiDeploymentListSearchParams,
44
InitializeDeploymentRequestBody,
5-
InitializeDeploymentResponseBody,
5+
type InitializeDeploymentResponseBody,
66
} from "@trigger.dev/core/v3";
77
import { $replica } from "~/db.server";
88
import { authenticateApiRequest } from "~/services/apiAuth.server";

apps/webapp/app/v3/services/initializeDeployment.server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ export class InitializeDeploymentService extends BaseService {
9999

100100
const { imageRef, isEcr, repoCreated } = imageRefResult;
101101

102+
// we keep using `BUILDING` as the initial status if not explicitly set
103+
// to avoid changing the behavior for deployments not created in the build server
104+
const initialStatus = payload.initialStatus ?? "BUILDING";
105+
102106
logger.debug("Creating deployment", {
103107
environmentId: environment.id,
104108
projectId: environment.projectId,
@@ -108,6 +112,7 @@ export class InitializeDeploymentService extends BaseService {
108112
imageRef,
109113
isEcr,
110114
repoCreated,
115+
initialStatus,
111116
});
112117

113118
const deployment = await this._prisma.workerDeployment.create({
@@ -116,7 +121,7 @@ export class InitializeDeploymentService extends BaseService {
116121
contentHash: payload.contentHash,
117122
shortCode: deploymentShortCode,
118123
version: nextVersion,
119-
status: "BUILDING",
124+
status: initialStatus,
120125
environmentId: environment.id,
121126
projectId: environment.projectId,
122127
externalBuildData,
@@ -131,7 +136,7 @@ export class InitializeDeploymentService extends BaseService {
131136

132137
await TimeoutDeploymentService.enqueue(
133138
deployment.id,
134-
"BUILDING",
139+
deployment.status,
135140
"Building timed out",
136141
new Date(Date.now() + env.DEPLOY_TIMEOUT_MS)
137142
);

packages/core/src/v3/schemas/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ export const InitializeDeploymentRequestBody = z.object({
419419
gitMeta: GitMeta.optional(),
420420
type: z.enum(["MANAGED", "UNMANAGED", "V1"]).optional(),
421421
runtime: z.string().optional(),
422+
initialStatus: z.enum(["PENDING", "BUILDING"]).optional(),
422423
});
423424

424425
export type InitializeDeploymentRequestBody = z.infer<typeof InitializeDeploymentRequestBody>;

0 commit comments

Comments
 (0)