diff --git a/src/github-communicator.ts b/src/github-communicator.ts index f9c1def..f938ae8 100644 --- a/src/github-communicator.ts +++ b/src/github-communicator.ts @@ -148,6 +148,9 @@ export class GithubCommunicator { currentStatus: StatusMessage.PR_CREATED, state: 'success' }, pullRequest); + + info(`Merging PR number: ${ createdPR.number }`); + await this.mergePR(createdPR.number); } else { info('More than 1 PR already exists. doing nothing...'); await this.setStatus({ @@ -166,6 +169,20 @@ export class GithubCommunicator { } } + async mergePR(pullNumber: number) { + try { + await this.octokit.rest.pulls.merge({ + owner: this.context.repo.owner, + repo: this.context.repo.repo, + pull_number: pullNumber + }); + info(`Merged PR number: ${ pullNumber }`); + } catch (error) { + const errorMessage = (error instanceof Error ? error.message : error); + throw new Error(`error while merging PR: ${ errorMessage }`); + } + } + addPRBodyFooter(body: string | null, footer: string) { let prBody = body || ''; prBody += '\n\n-----\n';