mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-18 03:02:56 +00:00
fix(webhook): include added and removed files in watchPaths validation
Currently, Dokploy only extracts modified files from webhook payloads. This causes watchPaths to fail matching commits that only add or remove files (such as adding new routes or deleting files), preventing auto-deployments. This commit updates the commit parsing logic to aggregate added, modified, and removed files.
This commit is contained in:
@@ -119,9 +119,11 @@ export default async function handler(
|
||||
}
|
||||
// If webhook doesn't provide image info, we'll use the configured image (old behavior)
|
||||
} else if (sourceType === "github") {
|
||||
const normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
application.watchPaths,
|
||||
@@ -150,21 +152,29 @@ export default async function handler(
|
||||
let normalizedCommits: string[] = [];
|
||||
|
||||
if (provider === "github") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
} else if (provider === "gitlab") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
} else if (provider === "gitea") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
} else if (provider === "soft-serve") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
}
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
@@ -179,9 +189,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,
|
||||
);
|
||||
const normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
application.watchPaths,
|
||||
@@ -225,9 +237,11 @@ export default async function handler(
|
||||
} else if (sourceType === "gitea") {
|
||||
const branchName = extractBranchName(req.headers, req.body);
|
||||
|
||||
const normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
application.watchPaths,
|
||||
|
||||
@@ -54,9 +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,
|
||||
);
|
||||
const normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
composeResult.watchPaths,
|
||||
@@ -74,9 +76,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,
|
||||
);
|
||||
const normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
composeResult.watchPaths,
|
||||
@@ -125,17 +129,23 @@ export default async function handler(
|
||||
let normalizedCommits: string[] = [];
|
||||
|
||||
if (provider === "github") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
} else if (provider === "gitlab") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
} else if (provider === "gitea") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
}
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
@@ -150,9 +160,11 @@ export default async function handler(
|
||||
} else if (sourceType === "gitea") {
|
||||
const branchName = extractBranchName(req.headers, req.body);
|
||||
|
||||
const normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits = req.body?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
composeResult.watchPaths,
|
||||
|
||||
@@ -223,9 +223,11 @@ export default async function handler(
|
||||
const deploymentTitle = extractCommitMessage(req.headers, req.body);
|
||||
const deploymentHash = extractHash(req.headers, req.body);
|
||||
const owner = getGithubRepositoryOwner(githubBody);
|
||||
const normalizedCommits = githubBody?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits = githubBody?.commits?.flatMap((commit: any) => [
|
||||
...(commit.added || []),
|
||||
...(commit.modified || []),
|
||||
...(commit.removed || []),
|
||||
]);
|
||||
|
||||
const apps = await db.query.applications.findMany({
|
||||
where: and(
|
||||
|
||||
Reference in New Issue
Block a user