5
0
Fork 0
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:
Cooper 2023-04-03 16:46:31 -04:00
parent 09faa1aae8
commit 83467da07b
No known key found for this signature in database
GPG key ID: DF6ECEF0888ECA4B

View file

@ -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(