fix: handle forked repositories

This commit is contained in:
Andras Bacsai
2022-10-02 09:16:51 +00:00
parent 0b067364a9
commit 8dbcf257c4
4 changed files with 9 additions and 3 deletions

View File

@@ -148,7 +148,7 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promi
const pullmergeRequestId = body.number.toString();
const pullmergeRequestAction = body.action;
const sourceBranch = body.pull_request.head.ref.includes('/') ? body.pull_request.head.ref.split('/')[2] : body.pull_request.head.ref;
console.log({sourceBranch, sourceRepository: body.pull_request.head.repo.full_name})
const sourceRepository = body.pull_request.head.repo.full_name
if (!allowedActions.includes(pullmergeRequestAction)) {
throw { status: 500, message: 'Action not allowed.' }
}
@@ -186,6 +186,7 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promi
data: {
pullmergeRequestId,
sourceBranch,
sourceRepository,
customDomain: `${protocol}${pullmergeRequestId}.${getDomain(application.fqdn)}`,
application: { connect: { id: application.id } }
}
@@ -206,6 +207,7 @@ export async function gitHubEvents(request: FastifyRequest<GitHubEvents>): Promi
await prisma.build.create({
data: {
id: buildId,
sourceRepository,
pullmergeRequestId,
previewApplicationId,
sourceBranch,