From 58aaf6e002ded47eaa6daec32e89efd3fb93e198 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 1 Sep 2024 17:50:00 -0600 Subject: [PATCH] refactor: add gitlab and bitbucket webhook support --- apps/dokploy/pages/api/deploy/[refreshToken].ts | 12 ++++++++++++ apps/dokploy/server/api/routers/application.ts | 1 + apps/dokploy/server/utils/providers/gitlab.ts | 2 -- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/pages/api/deploy/[refreshToken].ts b/apps/dokploy/pages/api/deploy/[refreshToken].ts index d65f68345..7b4e0a757 100644 --- a/apps/dokploy/pages/api/deploy/[refreshToken].ts +++ b/apps/dokploy/pages/api/deploy/[refreshToken].ts @@ -66,6 +66,18 @@ export default async function handler( res.status(301).json({ message: "Branch Not Match" }); return; } + } else if (sourceType === "gitlab") { + const branchName = extractBranchName(req.headers, req.body); + if (!branchName || branchName !== application.gitlabBranch) { + res.status(301).json({ message: "Branch Not Match" }); + return; + } + } else if (sourceType === "bitbucket") { + const branchName = extractBranchName(req.headers, req.body); + if (!branchName || branchName !== application.bitbucketBranch) { + res.status(301).json({ message: "Branch Not Match" }); + return; + } } try { diff --git a/apps/dokploy/server/api/routers/application.ts b/apps/dokploy/server/api/routers/application.ts index 0258068a2..ea1eaa589 100644 --- a/apps/dokploy/server/api/routers/application.ts +++ b/apps/dokploy/server/api/routers/application.ts @@ -226,6 +226,7 @@ export const applicationRouter = createTRPCRouter({ applicationStatus: "idle", gitlabId: input.gitlabId, gitlabProjectId: input.gitlabProjectId, + gitlabPathNamespace: input.gitlabPathNamespace, }); return true; diff --git a/apps/dokploy/server/utils/providers/gitlab.ts b/apps/dokploy/server/utils/providers/gitlab.ts index 8b45cf364..f3145c1b1 100644 --- a/apps/dokploy/server/utils/providers/gitlab.ts +++ b/apps/dokploy/server/utils/providers/gitlab.ts @@ -93,8 +93,6 @@ export const cloneGitlabRepository = async ( const writeStream = createWriteStream(logPath, { flags: "a" }); const { appName, - gitlabRepository, - gitlabOwner, gitlabBranch, gitlabId, gitlabProvider,