From a4e4d1c4676ed58e66cdebe667a3ae67b06e45c1 Mon Sep 17 00:00:00 2001 From: Jason Parks Date: Thu, 20 Mar 2025 13:50:55 -0600 Subject: [PATCH] Fix Gitea watch branch validation logic --- .../pages/api/deploy/[refreshToken].ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/dokploy/pages/api/deploy/[refreshToken].ts b/apps/dokploy/pages/api/deploy/[refreshToken].ts index d54c8f40..349f5f64 100644 --- a/apps/dokploy/pages/api/deploy/[refreshToken].ts +++ b/apps/dokploy/pages/api/deploy/[refreshToken].ts @@ -130,6 +130,21 @@ 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 shouldDeployPaths = shouldDeploy( + application.watchPaths, + normalizedCommits, + ); + + if (!shouldDeployPaths) { + res.status(301).json({ message: "Watch Paths Not Match" }); + return; + } + if (!branchName || branchName !== application.giteaBranch) { res.status(301).json({ message: "Branch Not Match" }); return; @@ -230,12 +245,6 @@ export const extractCommitMessage = (headers: any, body: any) => { : "NEW COMMIT"; } - if (headers["user-agent"]?.includes("Go-http-client")) { - if (body.push_data && body.repository) { - return `Docker image pushed: ${body.repository.repo_name}:${body.push_data.tag} by ${body.push_data.pusher}`; - } - } - return "NEW CHANGES"; };