mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-20 13:05:44 +00:00
feat: support combining path and message inputs using $path placeholder
Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
5b837e833d
commit
981267b215
3 changed files with 69 additions and 4 deletions
|
|
@ -52,6 +52,7 @@ export async function getBody(): Promise<string> {
|
|||
})
|
||||
const prefixInput = core.getInput("prefix", {required: false})
|
||||
const suffixInput = core.getInput("suffix", {required: false})
|
||||
const messageInput = core.getInput("message", {required: false})
|
||||
|
||||
let body: string
|
||||
if (pathInput && pathInput.length > 0) {
|
||||
|
|
@ -60,7 +61,14 @@ export async function getBody(): Promise<string> {
|
|||
followSymbolicLinks,
|
||||
matchDirectories: false,
|
||||
})
|
||||
body = (await globber.glob()).map(path => readFileSync(path, "utf-8")).join("\n")
|
||||
const fileContent = (await globber.glob())
|
||||
.map(path => readFileSync(path, "utf-8"))
|
||||
.join("\n")
|
||||
if (messageInput && messageInput.includes("$path")) {
|
||||
body = messageInput.replace(/\$path/g, fileContent)
|
||||
} else {
|
||||
body = fileContent
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
core.setFailed(error.message)
|
||||
|
|
@ -68,7 +76,7 @@ export async function getBody(): Promise<string> {
|
|||
return ""
|
||||
}
|
||||
} else {
|
||||
body = core.getInput("message", {required: false})
|
||||
body = messageInput
|
||||
}
|
||||
|
||||
if (prefixInput || suffixInput) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue