mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-15 20:56:31 +00:00
26 lines
782 B
TypeScript
26 lines
782 B
TypeScript
function headerComment(header) {
|
|
return `<!-- Sticky Pull Request Comment${header} -->`;
|
|
}
|
|
|
|
export async function findPreviousComment(octokit, repo, issue_number, header) {
|
|
const { data: comments } = await octokit.issues.listComments({
|
|
...repo,
|
|
issue_number
|
|
});
|
|
const h = headerComment(header);
|
|
return comments.find(comment => comment.body.startsWith(h));
|
|
}
|
|
export async function updateComment(octokit, repo, comment_id, body, header) {
|
|
await octokit.issues.updateComment({
|
|
...repo,
|
|
comment_id,
|
|
body: `${headerComment(header)}\n${body}`
|
|
});
|
|
}
|
|
export async function createComment(octokit, repo, issue_number, body, header) {
|
|
await octokit.issues.createComment({
|
|
...repo,
|
|
issue_number,
|
|
body: `${headerComment(header)}\n${body}`
|
|
});
|
|
}
|