mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 20:41:15 +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) {
|
export async function findPreviousComment(octokit, repo, issue_number) {
|
||||||
const { data: comments } = await octokit.issues.listComments({
|
const { data: comments } = await octokit.issues.listComments({
|
||||||
...repo,
|
...repo,
|
||||||
issue_number
|
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) {
|
export async function updateComment(octokit, repo, comment_id, body) {
|
||||||
await octokit.issues.updateComment({
|
await octokit.issues.updateComment({
|
||||||
...repo,
|
...repo,
|
||||||
comment_id,
|
comment_id,
|
||||||
body
|
body: `${HEADER}\n${body}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export async function createComment(octokit, repo, issue_number, body) {
|
export async function createComment(octokit, repo, issue_number, body) {
|
||||||
await octokit.issues.createComment({
|
await octokit.issues.createComment({
|
||||||
...repo,
|
...repo,
|
||||||
issue_number,
|
issue_number,
|
||||||
body
|
body: `${HEADER}\n${body}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue