π·(ci) add commit-format job #1
Workflow file for this run
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: Pull Request Validation | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| types: [ opened, synchronize, reopened ] | |
| jobs: | |
| commit-format: | |
| name: Check Commit Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check single commit and format | |
| run: | | |
| # Get all PR commits | |
| BASE_SHA=$(git merge-base origin/main HEAD) | |
| COMMITS=$(git rev-list --reverse $BASE_SHA..HEAD) | |
| echo "Commits in this PR:" | |
| echo "$COMMITS" | |
| # Commit message schema regex | |
| SCHEMA_REGEX="^(π¨|β‘οΈ|π₯|π|ποΈ|β¨|π|π|π|π|β |ποΈ|π|π|π¨|π§|π|β¬οΈ|β¬οΈ|π|π·|π|β»οΈ|β|β|π§|π¨|π|βοΈ|π©|βͺοΈ|π|π¦οΈ|π½οΈ|π|π|π₯|π±|βΏοΈ|π‘|π»|π¬|ποΈ|π|π|π₯|πΈ|ποΈ|π±|π€‘|π₯|π|πΈ|βοΈ|ποΈ|π·οΈ|π±|π©|π₯ |π«|ποΈ|π|π©Ή|π§|β°οΈ|π§ͺ|π|π©Ί|π§±|π§βπ»|πΈ|π§΅|π¦Ί|βοΈ)\\([a-z0-9:-]+\\) [a-z].{1,50}" | |
| # Validate commit message schema | |
| INVALID_COMMITS=0 | |
| for commit in $COMMITS; do | |
| MESSAGE=$(git log --format=%s -n 1 $commit) | |
| echo "Checking commit $commit: $MESSAGE" | |
| if ! echo "$MESSAGE" | grep -qE "$SCHEMA_REGEX"; then | |
| INVALID_COMMITS=$((INVALID_COMMITS + 1)) | |
| fi | |
| done | |
| if [ $INVALID_COMMITS -gt 0 ]; then | |
| echo "β $INVALID_COMMITS commit(s) with invalid format detected" | |
| echo "Required format: <emoji>(<scope>) <subject>" | |
| echo "Example: β¨(auth) add support for HTTP basic auth" | |
| echo "Use 'bin/cz commit' to create commits with the correct format" | |
| exit 1 | |
| fi | |
| echo "β All commits have valid format" |