diff --git a/apps/dokploy/pages/api/deploy/github.ts b/apps/dokploy/pages/api/deploy/github.ts index 4438366f6a..4a5f126f62 100644 --- a/apps/dokploy/pages/api/deploy/github.ts +++ b/apps/dokploy/pages/api/deploy/github.ts @@ -471,10 +471,6 @@ export default async function handler( if (!hasLabel) continue; } - const previewLimit = app?.previewLimit || 0; - if (app?.previewDeployments?.length > previewLimit) { - continue; - } const previewDeploymentResult = await findPreviewDeploymentByApplicationId(app.applicationId, prId); @@ -482,6 +478,11 @@ export default async function handler( previewDeploymentResult?.previewDeploymentId || ""; if (!previewDeploymentResult && shouldCreateDeployment) { + // Only enforce the limit for new previews, not updates to existing ones + const previewLimit = app?.previewLimit ?? 3; + if (app?.previewDeployments?.length >= previewLimit) { + continue; + } const previewDeployment = await createPreviewDeployment({ applicationId: app.applicationId as string, branch: prBranch, diff --git a/apps/dokploy/server/queues/deployments-queue.ts b/apps/dokploy/server/queues/deployments-queue.ts index e92f4c1921..9a0eec1d72 100644 --- a/apps/dokploy/server/queues/deployments-queue.ts +++ b/apps/dokploy/server/queues/deployments-queue.ts @@ -75,6 +75,19 @@ const createDeploymentWorker = () => } } catch (error) { console.log("Error", error); + if (job.data.applicationType === "application") { + await updateApplicationStatus(job.data.applicationId, "error").catch( + () => {}, + ); + } else if (job.data.applicationType === "compose") { + await updateCompose(job.data.composeId, { + composeStatus: "error", + }).catch(() => {}); + } else if (job.data.applicationType === "application-preview") { + await updatePreviewDeployment(job.data.previewDeploymentId, { + previewStatus: "error", + }).catch(() => {}); + } } }, {