mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 22:29:45 +11:00
feat: add message-skipped input to action (#76)
* add message-skipped input to action
This commit is contained in:
parent
ec8c4b3b90
commit
e4a2f85328
5 changed files with 38 additions and 1 deletions
|
|
@ -69,6 +69,7 @@ jobs:
|
|||
| message-success | with | A message override, printed in case of success. | no | |
|
||||
| message-failure | with | A message override, printed in case of failure. | no | |
|
||||
| message-cancelled | with | A message override, printed in case of cancelled. | no | |
|
||||
| message-skipped | with | A message override, printed in case of skipped. | no | |
|
||||
| status | with | Required if you want to use message status overrides. | no | {{ job.status }} |
|
||||
| repo-token | with | Valid GitHub token, either the temporary token GitHub provides or a personal access token. | no | {{ github.token }} |
|
||||
| message-id | with | Message id to use when searching existing comments. If found, updates the existing (sticky comment). | no | |
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ type Inputs = {
|
|||
'message-success'?: string
|
||||
'message-failure'?: string
|
||||
'message-cancelled'?: string
|
||||
status?: 'success' | 'failure' | 'cancelled'
|
||||
'message-skipped'?: string
|
||||
status?: 'success' | 'failure' | 'cancelled' | 'skipped'
|
||||
}
|
||||
|
||||
const inputs: Inputs = {
|
||||
|
|
@ -307,4 +308,27 @@ describe('add-pr-comment action', () => {
|
|||
await run()
|
||||
expect(messagePayload?.body).toContain('666')
|
||||
})
|
||||
|
||||
it('overrides the default message with a skipped message on skipped', async () => {
|
||||
inputs.message = simpleMessage
|
||||
inputs['message-path'] = undefined
|
||||
inputs['repo-token'] = repoToken
|
||||
inputs['allow-repeats'] = 'false'
|
||||
inputs['message-skipped'] = '666'
|
||||
inputs.status = 'skipped'
|
||||
|
||||
const commentId = 123
|
||||
|
||||
getIssueCommentsResponse = [
|
||||
{
|
||||
id: commentId,
|
||||
},
|
||||
]
|
||||
postIssueCommentsResponse = {
|
||||
id: commentId,
|
||||
}
|
||||
|
||||
await run()
|
||||
expect(messagePayload?.body).toContain('666')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ inputs:
|
|||
message-cancelled:
|
||||
description: "Override the message when a run is cancelled."
|
||||
required: false
|
||||
message-skipped:
|
||||
description: "Override the message when a run is skipped."
|
||||
required: false
|
||||
issue:
|
||||
description: "Override the message when a run is cancelled."
|
||||
required: false
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ async function getInputs() {
|
|||
const messageSuccess = core.getInput(`message-success`);
|
||||
const messageFailure = core.getInput(`message-failure`);
|
||||
const messageCancelled = core.getInput(`message-cancelled`);
|
||||
const messageSkipped = core.getInput(`message-skipped`);
|
||||
if (status === 'success' && messageSuccess) {
|
||||
message = messageSuccess;
|
||||
}
|
||||
|
|
@ -64,6 +65,9 @@ async function getInputs() {
|
|||
if (status === 'cancelled' && messageCancelled) {
|
||||
message = messageCancelled;
|
||||
}
|
||||
if (status === 'skipped' && messageSkipped) {
|
||||
message = messageSkipped;
|
||||
}
|
||||
if (!message) {
|
||||
throw new Error('no message, check your message inputs');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ export async function getInputs(): Promise<Inputs> {
|
|||
const messageSuccess = core.getInput(`message-success`)
|
||||
const messageFailure = core.getInput(`message-failure`)
|
||||
const messageCancelled = core.getInput(`message-cancelled`)
|
||||
const messageSkipped = core.getInput(`message-skipped`)
|
||||
|
||||
if (status === 'success' && messageSuccess) {
|
||||
message = messageSuccess
|
||||
|
|
@ -62,6 +63,10 @@ export async function getInputs(): Promise<Inputs> {
|
|||
message = messageCancelled
|
||||
}
|
||||
|
||||
if (status === 'skipped' && messageSkipped) {
|
||||
message = messageSkipped
|
||||
}
|
||||
|
||||
if (!message) {
|
||||
throw new Error('no message, check your message inputs')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue