diff --git a/actions/deploy/application.ts b/actions/deploy/application.ts new file mode 100644 index 0000000..b68739b --- /dev/null +++ b/actions/deploy/application.ts @@ -0,0 +1,39 @@ +"use server"; + +import prisma from "@/lib/prisma"; + +export type NewApplication = { + serviceProvider: string; + git: { + repositoryId: number; + repositoryName: string; + branch: string; + path: string; + }; + autodeploy: boolean; + env: { + [key: string]: string; + }; + name: string; +}; + +export async function createApplication(app: NewApplication, workspace: string) { + const application = await prisma.application.create({ + data: { + name: app.name, + autoDeploy: app.autodeploy, + branch: app.git.branch, + path: app.git.path, + repositoryId: app.git.repositoryId.toString(), + repository: app.git.repositoryName, + serviceProvider: app.serviceProvider, + Workspace: { + connect: { + slug: workspace + } + } + }, + }); + + return application; +} \ No newline at end of file