mirror of
https://github.com/andwati/dokploy.git
synced 2026-12-04 08:48:45 +00:00
feat: Add custom title/description for deployments via API/CLI - Add optional title/description fields to deployment schemas - Update TRPC and external API endpoints - Replace generic "Manual deployment" with custom titles - Maintain backward compatibility with default values Fixes #1485
This commit is contained in:
+3
-10
@@ -5,7 +5,7 @@ import { zValidator } from "@hono/zod-validator";
|
|||||||
import { Inngest } from "inngest";
|
import { Inngest } from "inngest";
|
||||||
import { serve as serveInngest } from "inngest/hono";
|
import { serve as serveInngest } from "inngest/hono";
|
||||||
import { logger } from "./logger.js";
|
import { logger } from "./logger.js";
|
||||||
import { type DeployJob, deployJobSchema, deployRequestSchema } from "./schema.js";
|
import { type DeployJob, deployJobSchema } from "./schema.js";
|
||||||
import { deploy } from "./utils.js";
|
import { deploy } from "./utils.js";
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
@@ -84,22 +84,15 @@ app.use(async (c, next) => {
|
|||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/deploy", zValidator("json", deployRequestSchema), async (c) => {
|
app.post("/deploy", zValidator("json", deployJobSchema), async (c) => {
|
||||||
const data = c.req.valid("json");
|
const data = c.req.valid("json");
|
||||||
logger.info("Received deployment request", data);
|
logger.info("Received deployment request", data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Transform the request to the internal job format
|
|
||||||
const jobData: DeployJob = {
|
|
||||||
...data,
|
|
||||||
titleLog: data.title || "Manual deployment",
|
|
||||||
descriptionLog: data.description || "",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send event to Inngest instead of adding to Redis queue
|
// Send event to Inngest instead of adding to Redis queue
|
||||||
await inngest.send({
|
await inngest.send({
|
||||||
name: "deployment/requested",
|
name: "deployment/requested",
|
||||||
data: jobData,
|
data,
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info("Deployment event sent to Inngest", {
|
logger.info("Deployment event sent to Inngest", {
|
||||||
|
|||||||
+6
-36
@@ -3,8 +3,8 @@ import { z } from "zod";
|
|||||||
export const deployJobSchema = z.discriminatedUnion("applicationType", [
|
export const deployJobSchema = z.discriminatedUnion("applicationType", [
|
||||||
z.object({
|
z.object({
|
||||||
applicationId: z.string(),
|
applicationId: z.string(),
|
||||||
titleLog: z.string(),
|
titleLog: z.string().optional(),
|
||||||
descriptionLog: z.string(),
|
descriptionLog: z.string().optional(),
|
||||||
server: z.boolean().optional(),
|
server: z.boolean().optional(),
|
||||||
type: z.enum(["deploy", "redeploy"]),
|
type: z.enum(["deploy", "redeploy"]),
|
||||||
applicationType: z.literal("application"),
|
applicationType: z.literal("application"),
|
||||||
@@ -12,8 +12,8 @@ export const deployJobSchema = z.discriminatedUnion("applicationType", [
|
|||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
composeId: z.string(),
|
composeId: z.string(),
|
||||||
titleLog: z.string(),
|
titleLog: z.string().optional(),
|
||||||
descriptionLog: z.string(),
|
descriptionLog: z.string().optional(),
|
||||||
server: z.boolean().optional(),
|
server: z.boolean().optional(),
|
||||||
type: z.enum(["deploy", "redeploy"]),
|
type: z.enum(["deploy", "redeploy"]),
|
||||||
applicationType: z.literal("compose"),
|
applicationType: z.literal("compose"),
|
||||||
@@ -22,8 +22,8 @@ export const deployJobSchema = z.discriminatedUnion("applicationType", [
|
|||||||
z.object({
|
z.object({
|
||||||
applicationId: z.string(),
|
applicationId: z.string(),
|
||||||
previewDeploymentId: z.string(),
|
previewDeploymentId: z.string(),
|
||||||
titleLog: z.string(),
|
titleLog: z.string().optional(),
|
||||||
descriptionLog: z.string(),
|
descriptionLog: z.string().optional(),
|
||||||
server: z.boolean().optional(),
|
server: z.boolean().optional(),
|
||||||
type: z.enum(["deploy"]),
|
type: z.enum(["deploy"]),
|
||||||
applicationType: z.literal("application-preview"),
|
applicationType: z.literal("application-preview"),
|
||||||
@@ -31,35 +31,5 @@ export const deployJobSchema = z.discriminatedUnion("applicationType", [
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const deployRequestSchema = z.discriminatedUnion("applicationType", [
|
|
||||||
z.object({
|
|
||||||
applicationId: z.string(),
|
|
||||||
title: z.string().optional(),
|
|
||||||
description: z.string().optional(),
|
|
||||||
server: z.boolean().optional(),
|
|
||||||
type: z.enum(["deploy", "redeploy"]),
|
|
||||||
applicationType: z.literal("application"),
|
|
||||||
serverId: z.string().min(1),
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
composeId: z.string(),
|
|
||||||
title: z.string().optional(),
|
|
||||||
description: z.string().optional(),
|
|
||||||
server: z.boolean().optional(),
|
|
||||||
type: z.enum(["deploy", "redeploy"]),
|
|
||||||
applicationType: z.literal("compose"),
|
|
||||||
serverId: z.string().min(1),
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
applicationId: z.string(),
|
|
||||||
previewDeploymentId: z.string(),
|
|
||||||
title: z.string().optional(),
|
|
||||||
description: z.string().optional(),
|
|
||||||
server: z.boolean().optional(),
|
|
||||||
type: z.enum(["deploy"]),
|
|
||||||
applicationType: z.literal("application-preview"),
|
|
||||||
serverId: z.string().min(1),
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
|
|
||||||
export type DeployJob = z.infer<typeof deployJobSchema>;
|
export type DeployJob = z.infer<typeof deployJobSchema>;
|
||||||
|
|||||||
+10
-10
@@ -18,14 +18,14 @@ export const deploy = async (job: DeployJob) => {
|
|||||||
if (job.type === "redeploy") {
|
if (job.type === "redeploy") {
|
||||||
await rebuildRemoteApplication({
|
await rebuildRemoteApplication({
|
||||||
applicationId: job.applicationId,
|
applicationId: job.applicationId,
|
||||||
titleLog: job.titleLog,
|
titleLog: job.titleLog || "Rebuild deployment",
|
||||||
descriptionLog: job.descriptionLog,
|
descriptionLog: job.descriptionLog || "",
|
||||||
});
|
});
|
||||||
} else if (job.type === "deploy") {
|
} else if (job.type === "deploy") {
|
||||||
await deployRemoteApplication({
|
await deployRemoteApplication({
|
||||||
applicationId: job.applicationId,
|
applicationId: job.applicationId,
|
||||||
titleLog: job.titleLog,
|
titleLog: job.titleLog || "Manual deployment",
|
||||||
descriptionLog: job.descriptionLog,
|
descriptionLog: job.descriptionLog || "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,14 +38,14 @@ export const deploy = async (job: DeployJob) => {
|
|||||||
if (job.type === "redeploy") {
|
if (job.type === "redeploy") {
|
||||||
await rebuildRemoteCompose({
|
await rebuildRemoteCompose({
|
||||||
composeId: job.composeId,
|
composeId: job.composeId,
|
||||||
titleLog: job.titleLog,
|
titleLog: job.titleLog || "Rebuild deployment",
|
||||||
descriptionLog: job.descriptionLog,
|
descriptionLog: job.descriptionLog || "",
|
||||||
});
|
});
|
||||||
} else if (job.type === "deploy") {
|
} else if (job.type === "deploy") {
|
||||||
await deployRemoteCompose({
|
await deployRemoteCompose({
|
||||||
composeId: job.composeId,
|
composeId: job.composeId,
|
||||||
titleLog: job.titleLog,
|
titleLog: job.titleLog || "Manual deployment",
|
||||||
descriptionLog: job.descriptionLog,
|
descriptionLog: job.descriptionLog || "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,8 +57,8 @@ export const deploy = async (job: DeployJob) => {
|
|||||||
if (job.type === "deploy") {
|
if (job.type === "deploy") {
|
||||||
await deployRemotePreviewApplication({
|
await deployRemotePreviewApplication({
|
||||||
applicationId: job.applicationId,
|
applicationId: job.applicationId,
|
||||||
titleLog: job.titleLog,
|
titleLog: job.titleLog || "Preview Deployment",
|
||||||
descriptionLog: job.descriptionLog,
|
descriptionLog: job.descriptionLog || "",
|
||||||
previewDeploymentId: job.previewDeploymentId,
|
previewDeploymentId: job.previewDeploymentId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user