Skip to content

Commit 02685fd

Browse files
authored
Merge pull request #2507 from Harikrishnan1367709/Allow-setting-a-title/description-for-deployments-via-API-or-CLI-#1485-Harikrishnan
feat: Add custom title/description support for API/CLI deployments (#1485)
2 parents 30a2d78 + fc2bd44 commit 02685fd

File tree

6 files changed

+64
-28
lines changed

6 files changed

+64
-28
lines changed

apps/api/src/schema.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import { z } from "zod";
33
export const deployJobSchema = z.discriminatedUnion("applicationType", [
44
z.object({
55
applicationId: z.string(),
6-
titleLog: z.string(),
7-
descriptionLog: z.string(),
6+
titleLog: z.string().optional(),
7+
descriptionLog: z.string().optional(),
88
server: z.boolean().optional(),
99
type: z.enum(["deploy", "redeploy"]),
1010
applicationType: z.literal("application"),
1111
serverId: z.string().min(1),
1212
}),
1313
z.object({
1414
composeId: z.string(),
15-
titleLog: z.string(),
16-
descriptionLog: z.string(),
15+
titleLog: z.string().optional(),
16+
descriptionLog: z.string().optional(),
1717
server: z.boolean().optional(),
1818
type: z.enum(["deploy", "redeploy"]),
1919
applicationType: z.literal("compose"),
@@ -22,8 +22,8 @@ export const deployJobSchema = z.discriminatedUnion("applicationType", [
2222
z.object({
2323
applicationId: z.string(),
2424
previewDeploymentId: z.string(),
25-
titleLog: z.string(),
26-
descriptionLog: z.string(),
25+
titleLog: z.string().optional(),
26+
descriptionLog: z.string().optional(),
2727
server: z.boolean().optional(),
2828
type: z.enum(["deploy"]),
2929
applicationType: z.literal("application-preview"),

apps/api/src/utils.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export const deploy = async (job: DeployJob) => {
1818
if (job.type === "redeploy") {
1919
await rebuildRemoteApplication({
2020
applicationId: job.applicationId,
21-
titleLog: job.titleLog,
22-
descriptionLog: job.descriptionLog,
21+
titleLog: job.titleLog || "Rebuild deployment",
22+
descriptionLog: job.descriptionLog || "",
2323
});
2424
} else if (job.type === "deploy") {
2525
await deployRemoteApplication({
2626
applicationId: job.applicationId,
27-
titleLog: job.titleLog,
28-
descriptionLog: job.descriptionLog,
27+
titleLog: job.titleLog || "Manual deployment",
28+
descriptionLog: job.descriptionLog || "",
2929
});
3030
}
3131
}
@@ -38,14 +38,14 @@ export const deploy = async (job: DeployJob) => {
3838
if (job.type === "redeploy") {
3939
await rebuildRemoteCompose({
4040
composeId: job.composeId,
41-
titleLog: job.titleLog,
42-
descriptionLog: job.descriptionLog,
41+
titleLog: job.titleLog || "Rebuild deployment",
42+
descriptionLog: job.descriptionLog || "",
4343
});
4444
} else if (job.type === "deploy") {
4545
await deployRemoteCompose({
4646
composeId: job.composeId,
47-
titleLog: job.titleLog,
48-
descriptionLog: job.descriptionLog,
47+
titleLog: job.titleLog || "Manual deployment",
48+
descriptionLog: job.descriptionLog || "",
4949
});
5050
}
5151
}
@@ -57,8 +57,8 @@ export const deploy = async (job: DeployJob) => {
5757
if (job.type === "deploy") {
5858
await deployRemotePreviewApplication({
5959
applicationId: job.applicationId,
60-
titleLog: job.titleLog,
61-
descriptionLog: job.descriptionLog,
60+
titleLog: job.titleLog || "Preview Deployment",
61+
descriptionLog: job.descriptionLog || "",
6262
previewDeploymentId: job.previewDeploymentId,
6363
});
6464
}

apps/dokploy/server/api/routers/application.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ import {
4040
import { db } from "@/server/db";
4141
import {
4242
apiCreateApplication,
43+
apiDeployApplication,
4344
apiFindMonitoringStats,
4445
apiFindOneApplication,
46+
apiRedeployApplication,
4547
apiReloadApplication,
4648
apiSaveBitbucketProvider,
4749
apiSaveBuildType,
@@ -306,7 +308,7 @@ export const applicationRouter = createTRPCRouter({
306308
}),
307309

308310
redeploy: protectedProcedure
309-
.input(apiFindOneApplication)
311+
.input(apiRedeployApplication)
310312
.mutation(async ({ input, ctx }) => {
311313
const application = await findApplicationById(input.applicationId);
312314
if (
@@ -320,8 +322,8 @@ export const applicationRouter = createTRPCRouter({
320322
}
321323
const jobData: DeploymentJob = {
322324
applicationId: input.applicationId,
323-
titleLog: "Rebuild deployment",
324-
descriptionLog: "",
325+
titleLog: input.title || "Rebuild deployment",
326+
descriptionLog: input.description || "",
325327
type: "redeploy",
326328
applicationType: "application",
327329
server: !!application.serverId,
@@ -670,7 +672,7 @@ export const applicationRouter = createTRPCRouter({
670672
return true;
671673
}),
672674
deploy: protectedProcedure
673-
.input(apiFindOneApplication)
675+
.input(apiDeployApplication)
674676
.mutation(async ({ input, ctx }) => {
675677
const application = await findApplicationById(input.applicationId);
676678
if (
@@ -684,8 +686,8 @@ export const applicationRouter = createTRPCRouter({
684686
}
685687
const jobData: DeploymentJob = {
686688
applicationId: input.applicationId,
687-
titleLog: "Manual deployment",
688-
descriptionLog: "",
689+
titleLog: input.title || "Manual deployment",
690+
descriptionLog: input.description || "",
689691
type: "deploy",
690692
applicationType: "application",
691693
server: !!application.serverId,

apps/dokploy/server/api/routers/compose.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ import { db } from "@/server/db";
4848
import {
4949
apiCreateCompose,
5050
apiDeleteCompose,
51+
apiDeployCompose,
5152
apiFetchServices,
5253
apiFindCompose,
5354
apiRandomizeCompose,
55+
apiRedeployCompose,
5456
apiUpdateCompose,
5557
compose as composeTable,
5658
} from "@/server/db/schema";
@@ -367,7 +369,7 @@ export const composeRouter = createTRPCRouter({
367369
}),
368370

369371
deploy: protectedProcedure
370-
.input(apiFindCompose)
372+
.input(apiDeployCompose)
371373
.mutation(async ({ input, ctx }) => {
372374
const compose = await findComposeById(input.composeId);
373375

@@ -382,10 +384,10 @@ export const composeRouter = createTRPCRouter({
382384
}
383385
const jobData: DeploymentJob = {
384386
composeId: input.composeId,
385-
titleLog: "Manual deployment",
387+
titleLog: input.title || "Manual deployment",
386388
type: "deploy",
387389
applicationType: "compose",
388-
descriptionLog: "",
390+
descriptionLog: input.description || "",
389391
server: !!compose.serverId,
390392
};
391393

@@ -404,7 +406,7 @@ export const composeRouter = createTRPCRouter({
404406
);
405407
}),
406408
redeploy: protectedProcedure
407-
.input(apiFindCompose)
409+
.input(apiRedeployCompose)
408410
.mutation(async ({ input, ctx }) => {
409411
const compose = await findComposeById(input.composeId);
410412
if (
@@ -418,10 +420,10 @@ export const composeRouter = createTRPCRouter({
418420
}
419421
const jobData: DeploymentJob = {
420422
composeId: input.composeId,
421-
titleLog: "Rebuild deployment",
423+
titleLog: input.title || "Rebuild deployment",
422424
type: "redeploy",
423425
applicationType: "compose",
424-
descriptionLog: "",
426+
descriptionLog: input.description || "",
425427
server: !!compose.serverId,
426428
};
427429
if (IS_CLOUD && compose.serverId) {

packages/server/src/db/schema/application.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,26 @@ export const apiFindOneApplication = createSchema
328328
})
329329
.required();
330330

331+
export const apiDeployApplication = createSchema
332+
.pick({
333+
applicationId: true,
334+
})
335+
.extend({
336+
applicationId: z.string().min(1),
337+
title: z.string().optional(),
338+
description: z.string().optional(),
339+
});
340+
341+
export const apiRedeployApplication = createSchema
342+
.pick({
343+
applicationId: true,
344+
})
345+
.extend({
346+
applicationId: z.string().min(1),
347+
title: z.string().optional(),
348+
description: z.string().optional(),
349+
});
350+
331351
export const apiReloadApplication = createSchema
332352
.pick({
333353
appName: true,

packages/server/src/db/schema/compose.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ export const apiFindCompose = z.object({
181181
composeId: z.string().min(1),
182182
});
183183

184+
export const apiDeployCompose = z.object({
185+
composeId: z.string().min(1),
186+
title: z.string().optional(),
187+
description: z.string().optional(),
188+
});
189+
190+
export const apiRedeployCompose = z.object({
191+
composeId: z.string().min(1),
192+
title: z.string().optional(),
193+
description: z.string().optional(),
194+
});
195+
184196
export const apiDeleteCompose = z.object({
185197
composeId: z.string().min(1),
186198
deleteVolumes: z.boolean(),

0 commit comments

Comments
 (0)