fix: Do not trigger >1 webhooks on GitLab
This commit is contained in:
parent
61716738ed
commit
3abe1610bf
@ -26,7 +26,6 @@ export async function newSource({ name, teamId, type, htmlUrl, apiUrl, organizat
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
export async function removeSource({ id }) {
|
export async function removeSource({ id }) {
|
||||||
// TODO: Disconnect application with this sourceId! Maybe not needed?
|
|
||||||
const source = await prisma.gitSource.delete({
|
const source = await prisma.gitSource.delete({
|
||||||
where: { id },
|
where: { id },
|
||||||
include: { githubApp: true, gitlabApp: true }
|
include: { githubApp: true, gitlabApp: true }
|
||||||
|
@ -22,6 +22,15 @@ export const post: RequestHandler = async (event) => {
|
|||||||
const allowedActions = ['opened', 'reopen', 'close', 'open', 'update'];
|
const allowedActions = ['opened', 'reopen', 'close', 'open', 'update'];
|
||||||
const body = await event.request.json();
|
const body = await event.request.json();
|
||||||
const buildId = cuid();
|
const buildId = cuid();
|
||||||
|
const webhookToken = event.request.headers.get('x-gitlab-token');
|
||||||
|
if (!webhookToken) {
|
||||||
|
return {
|
||||||
|
status: 500,
|
||||||
|
body: {
|
||||||
|
message: 'Ooops, something is not okay, are you okay?'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const { object_kind: objectKind } = body;
|
const { object_kind: objectKind } = body;
|
||||||
if (objectKind === 'push') {
|
if (objectKind === 'push') {
|
||||||
@ -77,16 +86,6 @@ export const post: RequestHandler = async (event) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if (objectKind === 'merge_request') {
|
} else if (objectKind === 'merge_request') {
|
||||||
const webhookToken = event.request.headers.get('x-gitlab-token');
|
|
||||||
if (!webhookToken) {
|
|
||||||
return {
|
|
||||||
status: 500,
|
|
||||||
body: {
|
|
||||||
message: 'Ooops, something is not okay, are you okay?'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const isDraft = body.object_attributes.work_in_progress;
|
const isDraft = body.object_attributes.work_in_progress;
|
||||||
const action = body.object_attributes.action;
|
const action = body.object_attributes.action;
|
||||||
const projectId = Number(body.project.id);
|
const projectId = Number(body.project.id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user