feat: implement error notification as pr comment

This commit is contained in:
Andrea Lamparelli 2024-04-04 21:42:31 +02:00
parent 6042bcc40b
commit c02522a9f1
27 changed files with 432 additions and 35 deletions

View file

@ -9,6 +9,7 @@ import { BackportPullRequest, GitClientType, GitPullRequest } from "@bp/service/
import LoggerService from "@bp/service/logger/logger-service";
import LoggerServiceFactory from "@bp/service/logger/logger-service-factory";
import { inferGitClient, inferGitApiUrl, getGitTokenFromEnv } from "@bp/service/git/git-util";
import { injectError } from "./runner-util";
interface Git {
gitClientType: GitClientType;
@ -92,6 +93,11 @@ export default class Runner {
});
} catch(error) {
this.logger.error(`Something went wrong backporting to ${pr.base}: ${error}`);
if (configs.errorNotification.enabled && configs.errorNotification.message.length > 0) {
// notify the failure as comment in the original pull request
const comment = injectError(configs.errorNotification.message, error as string);
gitApi.createPullRequestComment(configs.originalPullRequest.url, comment);
}
failures.push(error as string);
}
}