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.
This commit is contained in:
Mauricio Siu
2026-04-05 13:41:17 -06:00
parent 36e131cf12
commit dcb95374da
2 changed files with 35 additions and 7 deletions

View File

@@ -54,7 +54,11 @@ export default async function handler(
if (sourceType === "github") { if (sourceType === "github") {
const branchName = extractBranchName(req.headers, req.body); const branchName = extractBranchName(req.headers, req.body);
const normalizedCommits = 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( const shouldDeployPaths = shouldDeploy(
composeResult.watchPaths, composeResult.watchPaths,
@@ -73,7 +77,11 @@ export default async function handler(
} else if (sourceType === "gitlab") { } else if (sourceType === "gitlab") {
const branchName = extractBranchName(req.headers, req.body); const branchName = extractBranchName(req.headers, req.body);
const normalizedCommits = 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( const shouldDeployPaths = shouldDeploy(
composeResult.watchPaths, composeResult.watchPaths,
@@ -123,13 +131,25 @@ export default async function handler(
if (provider === "github") { if (provider === "github") {
normalizedCommits = 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") { } else if (provider === "gitlab") {
normalizedCommits = 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") { } else if (provider === "gitea") {
normalizedCommits = 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( const shouldDeployPaths = shouldDeploy(
@@ -145,7 +165,11 @@ export default async function handler(
const branchName = extractBranchName(req.headers, req.body); const branchName = extractBranchName(req.headers, req.body);
const normalizedCommits = 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( const shouldDeployPaths = shouldDeploy(
composeResult.watchPaths, composeResult.watchPaths,

View File

@@ -214,7 +214,11 @@ export default async function handler(
const deploymentHash = extractHash(req.headers, req.body); const deploymentHash = extractHash(req.headers, req.body);
const owner = githubBody?.repository?.owner?.name; const owner = githubBody?.repository?.owner?.name;
const normalizedCommits = 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({ const apps = await db.query.applications.findMany({
where: and( where: and(