diff --git a/src/service/git/git-client.ts b/src/service/git/git-client.ts index c9d0f10..c012b79 100644 --- a/src/service/git/git-client.ts +++ b/src/service/git/git-client.ts @@ -37,6 +37,11 @@ import { BackportPullRequest, GitClientType, GitPullRequest } from "@bp/service/ // WRITE + /** + * Add a comment about a failed backport. + */ + commentError(prUrl: string, message: string): Promise; + /** * Create a new pull request on the underneath git service * @param backport backport pull request data diff --git a/src/service/git/github/github-client.ts b/src/service/git/github/github-client.ts index 40f1831..e5e2df0 100644 --- a/src/service/git/github/github-client.ts +++ b/src/service/git/github/github-client.ts @@ -141,6 +141,16 @@ export default class GitHubClient implements GitClient { return data.html_url; } + async commentError(prUrl: string, message: string): Promise { + const { owner, project, id } = this.extractPullRequestData(prUrl); + await this.octokit.rest.issues.createComment({ + owner: owner, + repo: repo, + issue_number: id, + body: message, + }); + } + // UTILS /** diff --git a/src/service/runner/runner.ts b/src/service/runner/runner.ts index d4ddf42..322a4d3 100644 --- a/src/service/runner/runner.ts +++ b/src/service/runner/runner.ts @@ -91,7 +91,11 @@ export default class Runner { gitCli: git, }); } catch(error) { - this.logger.error(`Something went wrong backporting to ${pr.base}: ${error}`); + const error = `Something went wrong backporting to ${pr.base}: ${error}`; + if (!args.dryRun) { + gitApi.commentError(configs.originalPullRequest.url, error) + } + this.logger.error(error); failures.push(error as string); } }