Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,39 @@ describe('main.ts', () => {

expect(result).toBe(false)
})

it('Skips if is issue and no issue_message is provided', async () => {
github.context.payload.issue = { number: 10 }
github.context.payload.pull_request = undefined as any

core.getInput
.mockReset()
.mockReturnValueOnce('')
.mockReturnValueOnce('PR_MESSAGE')

await main.run()

expect(core.info).toHaveBeenCalledWith(
'Skipping... No issue message configured'
)
expect(mocktokit.paginate).not.toHaveBeenCalled()
})

it('Skips if is PR and no pr_message is provided', async () => {
github.context.payload.issue = undefined as any
github.context.payload.pull_request = { number: 10 }

core.getInput
.mockReset()
.mockReturnValueOnce('ISSUE_MESSAGE')
.mockReturnValueOnce('')

await main.run()

expect(core.info).toHaveBeenCalledWith(
'Skipping... No PR message configured'
)
expect(mocktokit.paginate).not.toHaveBeenCalled()
})
})
})
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ export async function run() {
)

// Get the action inputs.
const issueMessage: string = core.getInput('issue_message', {
required: true
})
const prMessage: string = core.getInput('pr_message', { required: true })
const issueMessage: string = core.getInput('issue_message')
if (isIssue && !issueMessage)
return core.info('Skipping... No issue message configured')

const prMessage: string = core.getInput('pr_message')
if (isPullRequest && !prMessage)
return core.info('Skipping... No PR message configured')

const octokit = new Octokit({
auth: core.getInput('repo_token', { required: true })
Expand Down