mirror of
https://github.com/webiny/action-conventional-commits.git
synced 2024-11-23 10:21:51 +01:00
feat: introduce allowed-commit-types
input
This commit is contained in:
parent
0cd283198a
commit
aa06c90208
3 changed files with 10 additions and 18 deletions
|
@ -4,6 +4,11 @@ inputs:
|
|||
GITHUB_TOKEN:
|
||||
description: 'GitHub token'
|
||||
required: false
|
||||
allowed-commit-types:
|
||||
description: 'Specify a comma separated list of allowed commit types'
|
||||
default: 'feat,fix,docs,style,refactor,test,build,perf,ci,chore,revert,merge,wip'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: node16
|
||||
main: dist/main/index.js
|
||||
|
|
|
@ -1,20 +1,4 @@
|
|||
const DEFAULT_COMMIT_TYPES = [
|
||||
"feat",
|
||||
"fix",
|
||||
"docs",
|
||||
"style",
|
||||
"refactor",
|
||||
"test",
|
||||
"build",
|
||||
"perf",
|
||||
"ci",
|
||||
"chore",
|
||||
"revert",
|
||||
"merge",
|
||||
"wip",
|
||||
];
|
||||
|
||||
const isValidCommitMessage = (message, availableTypes = DEFAULT_COMMIT_TYPES): boolean => {
|
||||
const isValidCommitMessage = (message: string, availableTypes: string[]): boolean => {
|
||||
// Exceptions.
|
||||
// This is a message that's auto-generated by git. Can't do much about it unfortunately. Let's allow it.
|
||||
if (message.startsWith("Merge ") || message.startsWith("Revert ")) {
|
||||
|
|
|
@ -19,7 +19,10 @@ async function run() {
|
|||
core.startGroup("Commit messages:");
|
||||
for (let i = 0; i < extractedCommits.length; i++) {
|
||||
let commit = extractedCommits[i];
|
||||
if (isValidCommitMessage(commit.message)) {
|
||||
|
||||
const allowedCommitTypes = core.getInput("allowed-commit-types").split(",");
|
||||
|
||||
if (isValidCommitMessage(commit.message, allowedCommitTypes)) {
|
||||
core.info(`✅ ${commit.message}`);
|
||||
} else {
|
||||
core.info(`🚩 ${commit.message}`);
|
||||
|
|
Loading…
Reference in a new issue