feat(git): configure Git hooks and enhance project setup #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Branch Name Check | |
| on: | |
| push: | |
| branches-ignore: | |
| - main | |
| - develop | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| jobs: | |
| check-branch-name: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check branch name | |
| run: | | |
| BRANCH=${GITHUB_REF#refs/heads/} | |
| if [[ ! $BRANCH =~ ^[a-zA-Z0-9]+/[a-zA-Z0-9-]+$ ]]; then | |
| echo "π« Branch name validation failed" | |
| echo "Branch: $BRANCH" | |
| echo "Required format: username/feature-name" | |
| echo "Examples:" | |
| echo "β john/add-footer" | |
| echo "β jane/fix-auth" | |
| echo "β main" | |
| echo "β feature-branch" | |
| echo "β fix_bug" | |
| exit 1 | |
| fi | |
| echo "β Branch name follows convention: $BRANCH" | |
| validate-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check commit message | |
| run: | | |
| git log -1 --pretty=format:"%s" | npx --no -- commitlint | |
| if [ $? -ne 0 ]; then | |
| echo "π« Commit message must follow conventional commits" | |
| echo "Examples:" | |
| echo "β feat: add new button component" | |
| echo "β fix: resolve auth redirect issue" | |
| echo "β docs: update README" | |
| exit 1 | |
| fi |