From 83467da07bcf182bf7dead9d98090d358bb760d8 Mon Sep 17 00:00:00 2001 From: Cooper Date: Mon, 3 Apr 2023 16:46:31 -0400 Subject: [PATCH] feat(action): adds flag to optionally fail on errors --- src/action.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/action.js b/src/action.js index 8d34009..e40d6c7 100644 --- a/src/action.js +++ b/src/action.js @@ -16,6 +16,8 @@ const { GITHUB_EVENT_NAME, GITHUB_SHA } = process.env const configPath = resolve(process.env.GITHUB_WORKSPACE, getInput('configFile')) +const failOnErrors = resolve(process.env.GITHUB_WORKSPACE, getInput('failOnErrors', { required: false })) + const getCommitDepth = () => { const commitDepthString = getInput('commitDepth') if (!commitDepthString?.trim()) return null @@ -145,6 +147,12 @@ const showLintResults = async ([from, to]) => { if (hasOnlyWarnings(lintedCommits)) { handleOnlyWarnings(formattedResults) + } else if (formattedResults && (failOnErrors == false)) { + // https://github.com/actions/toolkit/tree/master/packages/core#exit-codes + // this would be a good place to implement the setNeutral() when it's eventually implimented. + // for now it can pass with a check mark. + console.log('Passing despite errors ✅') + console.log(`You have commit messages with errors\n\n${formattedResults}`) } else if (formattedResults) { setFailedAction(formattedResults) } else { @@ -156,6 +164,7 @@ const exitWithMessage = (message) => (error) => { setFailedAction(`${message}\n${error.message}\n${error.stack}`) } + const commitLinterAction = () => getRangeForEvent() .catch(