Skip to content

Commit 83467da

Browse files
committed
feat(action): adds flag to optionally fail on errors
1 parent 09faa1a commit 83467da

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/action.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const { GITHUB_EVENT_NAME, GITHUB_SHA } = process.env
1616

1717
const configPath = resolve(process.env.GITHUB_WORKSPACE, getInput('configFile'))
1818

19+
const failOnErrors = resolve(process.env.GITHUB_WORKSPACE, getInput('failOnErrors', { required: false }))
20+
1921
const getCommitDepth = () => {
2022
const commitDepthString = getInput('commitDepth')
2123
if (!commitDepthString?.trim()) return null
@@ -145,6 +147,12 @@ const showLintResults = async ([from, to]) => {
145147

146148
if (hasOnlyWarnings(lintedCommits)) {
147149
handleOnlyWarnings(formattedResults)
150+
} else if (formattedResults && (failOnErrors == false)) {
151+
// https://github.com/actions/toolkit/tree/master/packages/core#exit-codes
152+
// this would be a good place to implement the setNeutral() when it's eventually implimented.
153+
// for now it can pass with a check mark.
154+
console.log('Passing despite errors ✅')
155+
console.log(`You have commit messages with errors\n\n${formattedResults}`)
148156
} else if (formattedResults) {
149157
setFailedAction(formattedResults)
150158
} else {
@@ -156,6 +164,7 @@ const exitWithMessage = (message) => (error) => {
156164
setFailedAction(`${message}\n${error.message}\n${error.stack}`)
157165
}
158166

167+
159168
const commitLinterAction = () =>
160169
getRangeForEvent()
161170
.catch(

0 commit comments

Comments
 (0)