Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: turn off autodeploy if double branch is configured

Andras Bacsaice31146a9c72
diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts
index 8f61997fbd..b5e2353354 100644
--- a/apps/api/src/routes/api/v1/applications/handlers.ts
+++ b/apps/api/src/routes/api/v1/applications/handlers.ts
@@ -267,6 +267,7 @@ export async function saveApplicationSettings(request: FastifyRequest<SaveApplic
const { debug, previews, dualCerts, autodeploy, branch, projectId } = request.body
const isDouble = await checkDoubleBranch(branch, projectId);
if (isDouble && autodeploy) {
+ await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false } })
throw { status: 500, message: 'Cannot activate automatic deployments until only one application is defined for this repository / branch.' }
}
await prisma.application.update({
@@ -526,6 +527,10 @@ export async function saveRepository(request, reply) {
data: { repository, branch, projectId, settings: { update: { autodeploy } } }
});
}
+ const isDouble = await checkDoubleBranch(branch, projectId);
+ if (isDouble) {
+ await prisma.applicationSettings.updateMany({ where: { application: { branch, projectId } }, data: { autodeploy: false } })
+ }
return reply.code(201).send()
} catch ({ status, message }) {
return errorHandler({ status, message })