From b3b8bc11c174b5faa6d31213144b948a82694145 Mon Sep 17 00:00:00 2001 From: Adrian Smijulj Date: Thu, 11 Jun 2020 08:42:06 +0200 Subject: [PATCH] feat: create action-conventional-commits --- dist/main/index.js | 16 +++++++++++++--- main.ts | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/dist/main/index.js b/dist/main/index.js index e9f1fa1..4814f0e 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -23572,13 +23572,23 @@ function run() { core.info(`No commits to check, skipping...`); return; } + let hasErrors; for (let i = 0; i < context.payload.commits.length; i++) { let commit = context.payload.commits[i]; - if (!isValidCommitMessage(commit.message)) { - core.setFailed(`According to the conventional-commits specification, commit message ${commit.message} is not valid.`); + if (isValidCommitMessage(commit.message)) { + core.info(`✅ ${commit.message}`); + } + else { + core.info(`🚩 ${commit.message}`); + hasErrors = true; } } - core.info("🎉 All commit messages are following the Conventional Commits specification."); + if (hasErrors) { + core.setFailed(`🚫 According to the conventional-commits specification, some of the commit messages are not valid.`); + } + else { + core.info("🎉 All commit messages are following the Conventional Commits specification."); + } }); } run(); diff --git a/main.ts b/main.ts index 942dbf3..d376bd8 100644 --- a/main.ts +++ b/main.ts @@ -14,16 +14,24 @@ async function run() { return; } + let hasErrors; for (let i = 0; i < context.payload.commits.length; i++) { let commit = context.payload.commits[i]; - if (!isValidCommitMessage(commit.message)) { - core.setFailed( - `According to the conventional-commits specification, commit message ${commit.message} is not valid.` - ); + if (isValidCommitMessage(commit.message)) { + core.info(`✅ ${commit.message}`); + } else { + core.info(`🚩 ${commit.message}`); + hasErrors = true; } } - core.info("🎉 All commit messages are following the Conventional Commits specification."); + if (hasErrors) { + core.setFailed( + `🚫 According to the conventional-commits specification, some of the commit messages are not valid.` + ); + } else { + core.info("🎉 All commit messages are following the Conventional Commits specification."); + } } run();