WitNote / .github /workflows /branch-naming.yml
AUXteam's picture
Upload folder using huggingface_hub
6a7089a verified
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"
# Allow long-running branches
if [[ "$BRANCH" =~ ^(main|develop|staging)$ ]]; then
echo "βœ… Long-running branch: $BRANCH"
exit 0
fi
# Allow dependabot branches
if [[ "$BRANCH" =~ ^dependabot/ ]]; then
echo "βœ… Dependabot branch: $BRANCH"
exit 0
fi
# Enforce prefix/description pattern
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."