feat: add clone by gitlab, github and bitbucket

This commit is contained in:
Mauricio Siu
2024-09-01 00:18:45 -06:00
parent a8408a11d9
commit 249fe8c7fe
6 changed files with 368 additions and 78 deletions

View File

@@ -21,6 +21,8 @@ import { createDeployment, updateDeploymentStatus } from "./deployment";
import { sendBuildErrorNotifications } from "@/server/utils/notifications/build-error";
import { sendBuildSuccessNotifications } from "@/server/utils/notifications/build-success";
import { validUniqueServerAppName } from "./project";
import { cloneGitlabRepository } from "@/server/utils/providers/gitlab";
import { cloneBitbucketRepository } from "@/server/utils/providers/bitbucket";
export type Application = typeof applications.$inferSelect;
export const createApplication = async (
@@ -81,6 +83,9 @@ export const findApplicationById = async (applicationId: string) => {
security: true,
ports: true,
registry: true,
gitlabProvider: true,
githubProvider: true,
bitbucketProvider: true,
},
});
if (!application) {
@@ -150,7 +155,13 @@ export const deployApplication = async ({
try {
if (application.sourceType === "github") {
await cloneGithubRepository(admin, application, deployment.logPath);
await cloneGithubRepository(application, deployment.logPath);
await buildApplication(application, deployment.logPath);
} else if (application.sourceType === "gitlab") {
await cloneGitlabRepository(application, deployment.logPath);
await buildApplication(application, deployment.logPath);
} else if (application.sourceType === "bitbucket") {
await cloneBitbucketRepository(application, deployment.logPath);
await buildApplication(application, deployment.logPath);
} else if (application.sourceType === "docker") {
await buildDocker(application, deployment.logPath);
@@ -214,6 +225,10 @@ export const rebuildApplication = async ({
try {
if (application.sourceType === "github") {
await buildApplication(application, deployment.logPath);
} else if (application.sourceType === "gitlab") {
await buildApplication(application, deployment.logPath);
} else if (application.sourceType === "bitbucket") {
await buildApplication(application, deployment.logPath);
} else if (application.sourceType === "docker") {
await buildDocker(application, deployment.logPath);
} else if (application.sourceType === "git") {

View File

@@ -142,10 +142,6 @@ export const haveGithubRequirements = (githubProvider: GithubProvider) => {
);
};
export const haveGitlabRequirements = (gitlabProvider: GitlabProvider) => {
return !!(gitlabProvider?.accessToken && gitlabProvider?.refreshToken);
};
export const getGitlabProvider = async (gitlabProviderId: string) => {
const gitlabProviderResult = await db.query.gitlabProvider.findFirst({
where: eq(gitlabProvider.gitlabProviderId, gitlabProviderId),