From 94b152067aca2c5d0596d04d785eeb7b5278b3a3 Mon Sep 17 00:00:00 2001 From: Emad-salah Date: Thu, 23 Jul 2020 15:08:46 +0100 Subject: [PATCH] Update patch version Added fallback condition to increment patch version in cases where no commits are present in the event (e.g. Pull Requests and custom events) --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6fcda37..f11657c 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,11 @@ Toolkit.run(async tools => { const pkg = tools.getPackageJSON() const event = tools.context.payload - const messages = event.commits.map(commit => commit.message + '\n' + commit.body) + if (!event.commits) { + console.log("Couldn't find any commits in this event, incrementing patch version...") + } + + const messages = event.commits ? event.commits.map(commit => commit.message + '\n' + commit.body) : [] const commitMessage = 'version bump to' const isVersionBump = messages.map(message => message.toLowerCase().includes(commitMessage)).includes(true)