Compare commits
1 Commits
chore/pre-
...
b5e6c1f159
| Author | SHA1 | Date | |
|---|---|---|---|
| b5e6c1f159 |
50
.gitea/workflows/commit-conventional.yml
Normal file
50
.gitea/workflows/commit-conventional.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Commit Message Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
conventional-commits:
|
||||
runs-on: [self-hosted, linux, k8s]
|
||||
|
||||
steps:
|
||||
- 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:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
BEFORE_SHA: ${{ github.event.before }}
|
||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
BASE_SHA=""
|
||||
|
||||
if [ "${EVENT_NAME}" = "pull_request" ] && [ -n "${PR_BASE_SHA:-}" ]; then
|
||||
BASE_SHA="${PR_BASE_SHA}"
|
||||
elif [ -n "${BEFORE_SHA:-}" ] && [ "${BEFORE_SHA}" != "0000000000000000000000000000000000000000" ]; then
|
||||
BASE_SHA="${BEFORE_SHA}"
|
||||
elif git rev-parse "${HEAD_SHA}^" >/dev/null 2>&1; then
|
||||
BASE_SHA="$(git rev-parse "${HEAD_SHA}^")"
|
||||
fi
|
||||
|
||||
if [ -n "${BASE_SHA}" ] && [ "${BASE_SHA}" != "${HEAD_SHA}" ]; then
|
||||
npx --no -- commitlint --from "${BASE_SHA}" --to "${HEAD_SHA}" --verbose
|
||||
else
|
||||
git log -1 --format=%s "${HEAD_SHA}" | npx --no -- commitlint --verbose
|
||||
fi
|
||||
19
.husky/pre-push
Executable file
19
.husky/pre-push
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
|
||||
case "$branch" in
|
||||
main|develop)
|
||||
echo "Direct pushes to $branch are not allowed."
|
||||
echo "Please create a feature/... or bugfix/... branch and open a PR/MR."
|
||||
exit 1
|
||||
;;
|
||||
feature/*|bugfix/*|hotfix/*|chore/*)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Invalid branch name: $branch"
|
||||
echo "Allowed branch prefixes: feature/*, bugfix/*, hotfix/*, chore/*"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user