fix: turn off autodeploy if double branch is configured

This commit is contained in:
Andras Bacsai 2022-07-14 08:00:57 +00:00
parent 344dd7db28
commit ce31146a9c

View File

@ -267,6 +267,7 @@ export async function saveApplicationSettings(request: FastifyRequest<SaveApplic
const { debug, previews, dualCerts, autodeploy, branch, projectId } = request.body const { debug, previews, dualCerts, autodeploy, branch, projectId } = request.body
const isDouble = await checkDoubleBranch(branch, projectId); const isDouble = await checkDoubleBranch(branch, projectId);
if (isDouble && autodeploy) { 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.' } throw { status: 500, message: 'Cannot activate automatic deployments until only one application is defined for this repository / branch.' }
} }
await prisma.application.update({ await prisma.application.update({
@ -526,6 +527,10 @@ export async function saveRepository(request, reply) {
data: { repository, branch, projectId, settings: { update: { autodeploy } } } 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() return reply.code(201).send()
} catch ({ status, message }) { } catch ({ status, message }) {
return errorHandler({ status, message }) return errorHandler({ status, message })