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