Skip to content

Feature/issue 47/initial setup #9

Feature/issue 47/initial setup

Feature/issue 47/initial setup #9

name: Branch Name Check
on:
pull_request:
types: [opened, synchronize]
jobs:
branch_name_check:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
id: extract_branch
run: echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
- name: Check branch name format
run: |
# Retrieve the branch name from the environment
BRANCH_NAME=$BRANCH_NAME
# Convert branch name to lowercase
BRANCH_NAME_LOWER=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]')
echo "Branch name: $BRANCH_NAME_LOWER"
# Validate the lowercase branch name
if [[ ! "$BRANCH_NAME_LOWER" =~ ^(bugfix|feature|hotfix|chore|release|test|doc|refactor)/issue-[0-9]+[/-][a-z0-9_-]+$ ]]; then
echo "Branch name $BRANCH_NAME_LOWER does not follow the required pattern: branch-type/issue-###/short-description"
echo "branch-type must be one of: bugfix, feature, hotfix, chore, release, test, doc, refactor"
exit 1
fi