mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 14:20:32 +11:00
Add update-only configuration option (#92)
This commit is contained in:
parent
387ece43e3
commit
1dff58b1a3
11 changed files with 3311 additions and 10787 deletions
|
|
@ -19,6 +19,7 @@ interface Inputs {
|
|||
pullRequestNumber?: number
|
||||
repo: string
|
||||
owner: string
|
||||
updateOnly: boolean
|
||||
}
|
||||
|
||||
export async function getInputs(): Promise<Inputs> {
|
||||
|
|
@ -35,6 +36,7 @@ export async function getInputs(): Promise<Inputs> {
|
|||
const allowRepeats = core.getInput('allow-repeats', { required: true }) === 'true'
|
||||
const refreshMessagePosition =
|
||||
core.getInput('refresh-message-position', { required: false }) === 'true'
|
||||
const updateOnly = core.getInput('update-only', { required: false }) === 'true'
|
||||
|
||||
if (messageInput && messagePath) {
|
||||
throw new Error('must specify only one, message or message-path')
|
||||
|
|
@ -88,5 +90,6 @@ export async function getInputs(): Promise<Inputs> {
|
|||
commitSha: github.context.sha,
|
||||
owner: repoOwner || payload.repo.owner,
|
||||
repo: repoName || payload.repo.repo,
|
||||
updateOnly: updateOnly,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ const run = async (): Promise<void> => {
|
|||
commitSha,
|
||||
repo,
|
||||
owner,
|
||||
updateOnly,
|
||||
} = await getInputs()
|
||||
|
||||
const octokit = github.getOctokit(repoToken)
|
||||
|
|
@ -60,6 +61,13 @@ const run = async (): Promise<void> => {
|
|||
}
|
||||
}
|
||||
|
||||
// if no existing comment and updateOnly is true, exit
|
||||
if (!existingCommentId && updateOnly) {
|
||||
core.info('no existing comment found and update-only is true, exiting')
|
||||
core.setOutput('comment-created', 'false')
|
||||
return
|
||||
}
|
||||
|
||||
let comment: CreateIssueCommentResponseData | null | undefined
|
||||
|
||||
const body = `${messageId}\n\n${message}`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue