From 16b2fef838d15e6f4c55dba0b2dbf4b5186c2742 Mon Sep 17 00:00:00 2001 From: Dafna Assaf <6606837+dassaf1@users.noreply.github.com> Date: Thu, 26 May 2022 16:27:21 +0300 Subject: [PATCH 1/3] automatically merge hotfix pull request to destination branch --- src/github-communicator.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/github-communicator.ts b/src/github-communicator.ts index f9c1def..55985ad 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(pull_number: number) { + try { + await this.octokit.rest.pulls.merge({ + owner: this.context.repo.owner, + repo: this.context.repo.repo, + pull_number: pull_number + }); + info(`Merged PR number: ${ pull_number }`); + } 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'; From 0b21a05f72bcd1fc62c4bbbe640faadcfd497822 Mon Sep 17 00:00:00 2001 From: Dafna Assaf <6606837+dassaf1@users.noreply.github.com> Date: Thu, 26 May 2022 16:53:48 +0300 Subject: [PATCH 2/3] changing pull_number parameter name to camel case --- src/github-communicator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/github-communicator.ts b/src/github-communicator.ts index 55985ad..93f3de3 100644 --- a/src/github-communicator.ts +++ b/src/github-communicator.ts @@ -169,14 +169,14 @@ export class GithubCommunicator { } } - async mergePR(pull_number: number) { + async mergePR(pullNumber: number) { try { await this.octokit.rest.pulls.merge({ owner: this.context.repo.owner, repo: this.context.repo.repo, - pull_number: pull_number + pullNumber: pullNumber }); - info(`Merged PR number: ${ pull_number }`); + info(`Merged PR number: ${ pullNumber }`); } catch (error) { const errorMessage = (error instanceof Error ? error.message : error); throw new Error(`error while merging PR: ${ errorMessage }`); From 0fd134227a5a5d137c5c2a4169f8a0d9aacb7f2d Mon Sep 17 00:00:00 2001 From: Dafna Assaf <6606837+dassaf1@users.noreply.github.com> Date: Thu, 26 May 2022 17:03:18 +0300 Subject: [PATCH 3/3] fix parameter name --- src/github-communicator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github-communicator.ts b/src/github-communicator.ts index 93f3de3..f938ae8 100644 --- a/src/github-communicator.ts +++ b/src/github-communicator.ts @@ -174,7 +174,7 @@ export class GithubCommunicator { await this.octokit.rest.pulls.merge({ owner: this.context.repo.owner, repo: this.context.repo.repo, - pullNumber: pullNumber + pull_number: pullNumber }); info(`Merged PR number: ${ pullNumber }`); } catch (error) {