mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 08:06:54 +00:00
feat(action): adds flag to optionally fail on errors
This commit is contained in:
parent
09faa1aae8
commit
83467da07b
1 changed files with 9 additions and 0 deletions
|
|
@ -16,6 +16,8 @@ const { GITHUB_EVENT_NAME, GITHUB_SHA } = process.env
|
||||||
|
|
||||||
const configPath = resolve(process.env.GITHUB_WORKSPACE, getInput('configFile'))
|
const configPath = resolve(process.env.GITHUB_WORKSPACE, getInput('configFile'))
|
||||||
|
|
||||||
|
const failOnErrors = resolve(process.env.GITHUB_WORKSPACE, getInput('failOnErrors', { required: false }))
|
||||||
|
|
||||||
const getCommitDepth = () => {
|
const getCommitDepth = () => {
|
||||||
const commitDepthString = getInput('commitDepth')
|
const commitDepthString = getInput('commitDepth')
|
||||||
if (!commitDepthString?.trim()) return null
|
if (!commitDepthString?.trim()) return null
|
||||||
|
|
@ -145,6 +147,12 @@ const showLintResults = async ([from, to]) => {
|
||||||
|
|
||||||
if (hasOnlyWarnings(lintedCommits)) {
|
if (hasOnlyWarnings(lintedCommits)) {
|
||||||
handleOnlyWarnings(formattedResults)
|
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) {
|
} else if (formattedResults) {
|
||||||
setFailedAction(formattedResults)
|
setFailedAction(formattedResults)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -156,6 +164,7 @@ const exitWithMessage = (message) => (error) => {
|
||||||
setFailedAction(`${message}\n${error.message}\n${error.stack}`)
|
setFailedAction(`${message}\n${error.message}\n${error.stack}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const commitLinterAction = () =>
|
const commitLinterAction = () =>
|
||||||
getRangeForEvent()
|
getRangeForEvent()
|
||||||
.catch(
|
.catch(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue