mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-15 20:56:31 +00:00
Merge pull request #1373 from NoRePercussions/move-header-to-bottom
Always move ID comment to end of message
This commit is contained in:
commit
debc36d8e8
1 changed files with 8 additions and 1 deletions
|
|
@ -19,6 +19,10 @@ function bodyWithHeader(body: string, header: string): string {
|
||||||
return `${body}\n${headerComment(header)}`
|
return `${body}\n${headerComment(header)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bodyWithoutHeader(body: string, header: string): string {
|
||||||
|
return body.replace(`\n${headerComment(header)}`, "");
|
||||||
|
}
|
||||||
|
|
||||||
export async function findPreviousComment(
|
export async function findPreviousComment(
|
||||||
octokit: InstanceType<typeof GitHub>,
|
octokit: InstanceType<typeof GitHub>,
|
||||||
repo: {
|
repo: {
|
||||||
|
|
@ -88,6 +92,9 @@ export async function updateComment(
|
||||||
if (!body && !previousBody)
|
if (!body && !previousBody)
|
||||||
return core.warning("Comment body cannot be blank")
|
return core.warning("Comment body cannot be blank")
|
||||||
|
|
||||||
|
if (previousBody)
|
||||||
|
let rawPreviousBody = bodyWithoutHeader(previousBody, header)
|
||||||
|
|
||||||
await octokit.graphql(
|
await octokit.graphql(
|
||||||
`
|
`
|
||||||
mutation($input: UpdateIssueCommentInput!) {
|
mutation($input: UpdateIssueCommentInput!) {
|
||||||
|
|
@ -103,7 +110,7 @@ export async function updateComment(
|
||||||
input: {
|
input: {
|
||||||
id,
|
id,
|
||||||
body: previousBody
|
body: previousBody
|
||||||
? `${previousBody}\n${body}`
|
? bodyWithHeader(`${rawPreviousBody}\n${body}`, header)
|
||||||
: bodyWithHeader(body, header)
|
: bodyWithHeader(body, header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue