diff --git a/apps/dokploy/server/utils/providers/git.ts b/apps/dokploy/server/utils/providers/git.ts index b6f23705..d9d16d1f 100644 --- a/apps/dokploy/server/utils/providers/git.ts +++ b/apps/dokploy/server/utils/providers/git.ts @@ -33,7 +33,9 @@ export const cloneGitRepository = async ( const knownHostsPath = path.join(SSH_PATH, "known_hosts"); try { - await addHostToKnownHosts(customGitUrl); + if (!isHttpOrHttps(customGitUrl)) { + await addHostToKnownHosts(customGitUrl); + } await recreateDirectory(outputPath); // const command = `GIT_SSH_COMMAND="ssh -i ${keyPath} -o UserKnownHostsFile=${knownHostsPath}" git clone --branch ${customGitBranch} --depth 1 ${customGitUrl} ${gitCopyPath} --progress`; // const { stdout, stderr } = await execAsync(command); @@ -84,6 +86,11 @@ export const cloneGitRepository = async ( } }; +const isHttpOrHttps = (url: string): boolean => { + const regex = /^https?:\/\//; + return regex.test(url); +}; + const addHostToKnownHosts = async (repositoryURL: string) => { const { domain, port } = sanitizeRepoPathSSH(repositoryURL); const knownHostsPath = path.join(SSH_PATH, "known_hosts"); @@ -121,7 +128,7 @@ const sanitizeRepoPathSSH = (input: string) => { return { user: found.groups?.user ?? "git", domain: found.groups?.domain, - port: 22, + port: Number(found.groups?.port ?? 22), owner: found.groups?.owner ?? "", repo: found.groups?.repo, get repoPath() {