| name: Branch Naming |
|
|
| on: |
| pull_request: |
| types: [opened, synchronize, reopened] |
|
|
| permissions: |
| contents: read |
|
|
| jobs: |
| check-branch-name: |
| name: Branch Name Convention |
| runs-on: ubuntu-latest |
| if: github.event.pull_request.draft == false |
| steps: |
| - name: Check branch name |
| run: | |
| BRANCH="${GITHUB_HEAD_REF}" |
| echo "Branch: $BRANCH" |
| |
| |
| if [[ "$BRANCH" =~ ^(main|develop|staging)$ ]]; then |
| echo "β
Long-running branch: $BRANCH" |
| exit 0 |
| fi |
|
|
| |
| if [[ "$BRANCH" =~ ^dependabot/ ]]; then |
| echo "β
Dependabot branch: $BRANCH" |
| exit 0 |
| fi |
|
|
| |
| PATTERN="^(feature|feat|fix|hotfix|docs|chore|refactor|test)/[a-z0-9][a-z0-9-]*$" |
| if [[ ! "$BRANCH" =~ $PATTERN ]]; then |
| echo "β Branch name '$BRANCH' doesn't match convention." |
| echo "" |
| echo "Expected format: <prefix>/<description>" |
| echo " Prefixes: feature, feat, fix, hotfix, docs, chore, refactor, test" |
| echo " Description: lowercase, hyphens, no special chars" |
| echo "" |
| echo "Examples:" |
| echo " feature/42-add-search-filter" |
| echo " fix/chrome-orphan-cleanup" |
| echo " hotfix/critical-api-fix" |
| echo " docs/update-docker-guide" |
| exit 1 |
| fi |
|
|
| echo "β
Branch name '$BRANCH' follows convention." |
|
|