Skip to content

Commit aa06c90

Browse files
committed
feat: introduce allowed-commit-types input
1 parent 0cd2831 commit aa06c90

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ inputs:
44
GITHUB_TOKEN:
55
description: 'GitHub token'
66
required: false
7+
allowed-commit-types:
8+
description: 'Specify a comma separated list of allowed commit types'
9+
default: 'feat,fix,docs,style,refactor,test,build,perf,ci,chore,revert,merge,wip'
10+
required: false
11+
712
runs:
813
using: node16
914
main: dist/main/index.js

src/isValidCommitMesage.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
const DEFAULT_COMMIT_TYPES = [
2-
"feat",
3-
"fix",
4-
"docs",
5-
"style",
6-
"refactor",
7-
"test",
8-
"build",
9-
"perf",
10-
"ci",
11-
"chore",
12-
"revert",
13-
"merge",
14-
"wip",
15-
];
16-
17-
const isValidCommitMessage = (message, availableTypes = DEFAULT_COMMIT_TYPES): boolean => {
1+
const isValidCommitMessage = (message: string, availableTypes: string[]): boolean => {
182
// Exceptions.
193
// This is a message that's auto-generated by git. Can't do much about it unfortunately. Let's allow it.
204
if (message.startsWith("Merge ") || message.startsWith("Revert ")) {

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ async function run() {
1919
core.startGroup("Commit messages:");
2020
for (let i = 0; i < extractedCommits.length; i++) {
2121
let commit = extractedCommits[i];
22-
if (isValidCommitMessage(commit.message)) {
22+
23+
const allowedCommitTypes = core.getInput("allowed-commit-types").split(",");
24+
25+
if (isValidCommitMessage(commit.message, allowedCommitTypes)) {
2326
core.info(`✅ ${commit.message}`);
2427
} else {
2528
core.info(`🚩 ${commit.message}`);

0 commit comments

Comments
 (0)