refactor: add gitlab and bitbucket webhook support

This commit is contained in:
Mauricio Siu 2024-09-01 17:50:00 -06:00
parent d57bbff87c
commit 58aaf6e002
3 changed files with 13 additions and 2 deletions

View File

@ -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 {

View File

@ -226,6 +226,7 @@ export const applicationRouter = createTRPCRouter({
applicationStatus: "idle",
gitlabId: input.gitlabId,
gitlabProjectId: input.gitlabProjectId,
gitlabPathNamespace: input.gitlabPathNamespace,
});
return true;

View File

@ -93,8 +93,6 @@ export const cloneGitlabRepository = async (
const writeStream = createWriteStream(logPath, { flags: "a" });
const {
appName,
gitlabRepository,
gitlabOwner,
gitlabBranch,
gitlabId,
gitlabProvider,