From dcb95374da0aa06ac81e5131423f8492d2a8ba71 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Sun, 5 Apr 2026 13:41:17 -0600 Subject: [PATCH] fix: also collect added/removed paths and filter nullish values commit.modified can be undefined causing micromatch to throw "Expected input to be a string". Also includes added and removed paths from commits so watch paths can match against all changed files. --- .../api/deploy/compose/[refreshToken].ts | 36 +++++++++++++++---- apps/dokploy/pages/api/deploy/github.ts | 6 +++- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts b/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts index d036a4b6f..9c1fb5207 100644 --- a/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts +++ b/apps/dokploy/pages/api/deploy/compose/[refreshToken].ts @@ -54,7 +54,11 @@ export default async function handler( if (sourceType === "github") { const branchName = extractBranchName(req.headers, req.body); const normalizedCommits = - req.body?.commits?.flatMap((commit: any) => commit.modified) || []; + req.body?.commits?.flatMap((commit: any) => [ + ...(commit.modified || []), + ...(commit.added || []), + ...(commit.removed || []), + ]).filter(Boolean) || []; const shouldDeployPaths = shouldDeploy( composeResult.watchPaths, @@ -73,7 +77,11 @@ export default async function handler( } else if (sourceType === "gitlab") { const branchName = extractBranchName(req.headers, req.body); const normalizedCommits = - req.body?.commits?.flatMap((commit: any) => commit.modified) || []; + req.body?.commits?.flatMap((commit: any) => [ + ...(commit.modified || []), + ...(commit.added || []), + ...(commit.removed || []), + ]).filter(Boolean) || []; const shouldDeployPaths = shouldDeploy( composeResult.watchPaths, @@ -123,13 +131,25 @@ export default async function handler( if (provider === "github") { normalizedCommits = - req.body?.commits?.flatMap((commit: any) => commit.modified) || []; + req.body?.commits?.flatMap((commit: any) => [ + ...(commit.modified || []), + ...(commit.added || []), + ...(commit.removed || []), + ]).filter(Boolean) || []; } else if (provider === "gitlab") { normalizedCommits = - req.body?.commits?.flatMap((commit: any) => commit.modified) || []; + req.body?.commits?.flatMap((commit: any) => [ + ...(commit.modified || []), + ...(commit.added || []), + ...(commit.removed || []), + ]).filter(Boolean) || []; } else if (provider === "gitea") { normalizedCommits = - req.body?.commits?.flatMap((commit: any) => commit.modified) || []; + req.body?.commits?.flatMap((commit: any) => [ + ...(commit.modified || []), + ...(commit.added || []), + ...(commit.removed || []), + ]).filter(Boolean) || []; } const shouldDeployPaths = shouldDeploy( @@ -145,7 +165,11 @@ export default async function handler( const branchName = extractBranchName(req.headers, req.body); const normalizedCommits = - req.body?.commits?.flatMap((commit: any) => commit.modified) || []; + req.body?.commits?.flatMap((commit: any) => [ + ...(commit.modified || []), + ...(commit.added || []), + ...(commit.removed || []), + ]).filter(Boolean) || []; const shouldDeployPaths = shouldDeploy( composeResult.watchPaths, diff --git a/apps/dokploy/pages/api/deploy/github.ts b/apps/dokploy/pages/api/deploy/github.ts index 84480a6bb..9a0dce1f5 100644 --- a/apps/dokploy/pages/api/deploy/github.ts +++ b/apps/dokploy/pages/api/deploy/github.ts @@ -214,7 +214,11 @@ export default async function handler( const deploymentHash = extractHash(req.headers, req.body); const owner = githubBody?.repository?.owner?.name; const normalizedCommits = - githubBody?.commits?.flatMap((commit: any) => commit.modified) || []; + githubBody?.commits?.flatMap((commit: any) => [ + ...(commit.modified || []), + ...(commit.added || []), + ...(commit.removed || []), + ]).filter(Boolean) || []; const apps = await db.query.applications.findMany({ where: and(