Compare commits
1 Commits
18f167418d
...
6e025107cb
| Author | SHA1 | Date | |
|---|---|---|---|
| 6e025107cb |
@@ -10,21 +10,7 @@ jobs:
|
|||||||
runs-on: [self-hosted, linux]
|
runs-on: [self-hosted, linux]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Validate commit messages
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci --ignore-scripts
|
|
||||||
|
|
||||||
- name: Validate commit messages with commitlint
|
|
||||||
env:
|
env:
|
||||||
EVENT_NAME: ${{ github.event_name }}
|
EVENT_NAME: ${{ github.event_name }}
|
||||||
BEFORE_SHA: ${{ github.event.before }}
|
BEFORE_SHA: ${{ github.event.before }}
|
||||||
@@ -63,7 +49,38 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${BASE_SHA}" ] && [ "${BASE_SHA}" != "${TARGET_SHA}" ]; then
|
if [ -n "${BASE_SHA}" ] && [ "${BASE_SHA}" != "${TARGET_SHA}" ]; then
|
||||||
npx --no -- commitlint --from "${BASE_SHA}" --to "${TARGET_SHA}" --verbose
|
MESSAGES="$(git log --format=%s "${BASE_SHA}..${TARGET_SHA}")"
|
||||||
else
|
else
|
||||||
git log -1 --format=%s "${TARGET_SHA}" | npx --no -- commitlint --verbose
|
MESSAGES="$(git log -1 --format=%s "${TARGET_SHA}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${MESSAGES}" ]; then
|
||||||
|
MESSAGES="$(git log -1 --format=%s "${TARGET_SHA}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PATTERN='^(build|chore|ci|docs|feat|fix|perf|refactor|style|test)(\([a-z0-9._/-]+\))?(!)?: .+'
|
||||||
|
FAILED=0
|
||||||
|
|
||||||
|
while IFS= read -r SUBJECT; do
|
||||||
|
[ -z "${SUBJECT}" ] && continue
|
||||||
|
|
||||||
|
if [[ "${SUBJECT}" =~ ^Merge[[:space:]] ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${SUBJECT}" =~ ^Revert[[:space:]] ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "${SUBJECT}" =~ ${PATTERN} ]]; then
|
||||||
|
echo "Invalid commit message: ${SUBJECT}"
|
||||||
|
FAILED=1
|
||||||
|
else
|
||||||
|
echo "OK: ${SUBJECT}"
|
||||||
|
fi
|
||||||
|
done <<< "${MESSAGES}"
|
||||||
|
|
||||||
|
if [ "${FAILED}" -ne 0 ]; then
|
||||||
|
echo "Conventional Commit check failed."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user