mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-04-24 20:32:14 +00:00
feat: comment on the original pull/merge request when on error
A comment is added to the original PR when a backport fails. The developers watching the PR will be notified even if they are not watching the CI. Fixes: https://github.com/kiegroup/git-backporting/issues/123
This commit is contained in:
parent
fc5dba6703
commit
ef940d1dbf
3 changed files with 20 additions and 1 deletions
|
@ -37,6 +37,11 @@ import { BackportPullRequest, GitClientType, GitPullRequest } from "@bp/service/
|
||||||
|
|
||||||
// WRITE
|
// WRITE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a comment about a failed backport.
|
||||||
|
*/
|
||||||
|
commentError(prUrl: string, message: string): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new pull request on the underneath git service
|
* Create a new pull request on the underneath git service
|
||||||
* @param backport backport pull request data
|
* @param backport backport pull request data
|
||||||
|
|
|
@ -141,6 +141,16 @@ export default class GitHubClient implements GitClient {
|
||||||
return data.html_url;
|
return data.html_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async commentError(prUrl: string, message: string): Promise<void> {
|
||||||
|
const { owner, project, id } = this.extractPullRequestData(prUrl);
|
||||||
|
await this.octokit.rest.issues.createComment({
|
||||||
|
owner: owner,
|
||||||
|
repo: repo,
|
||||||
|
issue_number: id,
|
||||||
|
body: message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// UTILS
|
// UTILS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -91,7 +91,11 @@ export default class Runner {
|
||||||
gitCli: git,
|
gitCli: git,
|
||||||
});
|
});
|
||||||
} catch(error) {
|
} 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);
|
failures.push(error as string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue