feat: support for fail-if-no-changes input

Currently if this action is used and no changes have been made to the
repository, the job will silently continue. This feature adds a new
flag `fail-if-no-changes`, which when enabled causes the job to fail
when there are no changes.
This commit is contained in:
Chris Buckley 2022-01-08 21:48:54 +00:00
parent dcd5fd746d
commit 171a10a802
7 changed files with 21 additions and 5 deletions

View file

@ -30,6 +30,7 @@ export interface Inputs {
teamReviewers: string[]
milestone: number
draft: boolean
failIfNoChanges: boolean
}
export async function createPullRequest(inputs: Inputs): Promise<void> {
@ -179,6 +180,10 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
)
core.endGroup()
if (['not-created', 'not-updated'].includes(result.action) && inputs.failIfNoChanges) {
throw new Error('No changes were made. Will not continue.')
}
if (['created', 'updated'].includes(result.action)) {
// The branch was created or updated
core.startGroup(