Skip to content

Commit

Permalink
feat(action): adds flag to optionally fail on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cmitzel-ncino committed Apr 3, 2023
1 parent 09faa1a commit 83467da
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -156,6 +164,7 @@ const exitWithMessage = (message) => (error) => {
setFailedAction(`${message}\n${error.message}\n${error.stack}`)
}


const commitLinterAction = () =>
getRangeForEvent()
.catch(
Expand Down

0 comments on commit 83467da

Please sign in to comment.