mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-21 05:25:43 +00:00
Add prefix and suffix inputs to wrap comment body
Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
58d8e91c23
commit
5b837e833d
4 changed files with 87 additions and 2 deletions
|
|
@ -50,13 +50,17 @@ export async function getBody(): Promise<string> {
|
|||
const followSymbolicLinks = core.getBooleanInput("follow_symbolic_links", {
|
||||
required: true,
|
||||
})
|
||||
const prefixInput = core.getInput("prefix", {required: false})
|
||||
const suffixInput = core.getInput("suffix", {required: false})
|
||||
|
||||
let body: string
|
||||
if (pathInput && pathInput.length > 0) {
|
||||
try {
|
||||
const globber = await create(pathInput.join("\n"), {
|
||||
followSymbolicLinks,
|
||||
matchDirectories: false,
|
||||
})
|
||||
return (await globber.glob()).map(path => readFileSync(path, "utf-8")).join("\n")
|
||||
body = (await globber.glob()).map(path => readFileSync(path, "utf-8")).join("\n")
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
core.setFailed(error.message)
|
||||
|
|
@ -64,6 +68,16 @@ export async function getBody(): Promise<string> {
|
|||
return ""
|
||||
}
|
||||
} else {
|
||||
return core.getInput("message", {required: false})
|
||||
body = core.getInput("message", {required: false})
|
||||
}
|
||||
|
||||
if (prefixInput || suffixInput) {
|
||||
const parts: string[] = []
|
||||
if (prefixInput) parts.push(prefixInput)
|
||||
parts.push(body)
|
||||
if (suffixInput) parts.push(suffixInput)
|
||||
return parts.join("\n")
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue