Compare commits
1 Commits
6e025107cb
...
18f167418d
| Author | SHA1 | Date | |
|---|---|---|---|
| 18f167418d |
@@ -10,7 +10,21 @@ jobs:
|
|||||||
runs-on: [self-hosted, linux]
|
runs-on: [self-hosted, linux]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Validate commit messages
|
- name: Checkout
|
||||||
|
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 }}
|
||||||
@@ -49,38 +63,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${BASE_SHA}" ] && [ "${BASE_SHA}" != "${TARGET_SHA}" ]; then
|
if [ -n "${BASE_SHA}" ] && [ "${BASE_SHA}" != "${TARGET_SHA}" ]; then
|
||||||
MESSAGES="$(git log --format=%s "${BASE_SHA}..${TARGET_SHA}")"
|
npx --no -- commitlint --from "${BASE_SHA}" --to "${TARGET_SHA}" --verbose
|
||||||
else
|
else
|
||||||
MESSAGES="$(git log -1 --format=%s "${TARGET_SHA}")"
|
git log -1 --format=%s "${TARGET_SHA}" | npx --no -- commitlint --verbose
|
||||||
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