mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 12:31:14 +00:00
feat: find & write with comment header
This commit is contained in:
parent
0c015d9eea
commit
9550af3011
1 changed files with 5 additions and 3 deletions
|
|
@ -1,21 +1,23 @@
|
|||
const HEADER = "<!-- Sticky Pull Request Comment -->";
|
||||
|
||||
export async function findPreviousComment(octokit, repo, issue_number) {
|
||||
const { data: comments } = await octokit.issues.listComments({
|
||||
...repo,
|
||||
issue_number
|
||||
});
|
||||
return comments.find(comment => comment.user.login === "github-actions[bot]");
|
||||
return comments.find(comment => comment.body.startsWith(HEADER));
|
||||
}
|
||||
export async function updateComment(octokit, repo, comment_id, body) {
|
||||
await octokit.issues.updateComment({
|
||||
...repo,
|
||||
comment_id,
|
||||
body
|
||||
body: `${HEADER}\n${body}`
|
||||
});
|
||||
}
|
||||
export async function createComment(octokit, repo, issue_number, body) {
|
||||
await octokit.issues.createComment({
|
||||
...repo,
|
||||
issue_number,
|
||||
body
|
||||
body: `${HEADER}\n${body}`
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue