Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate rules for GitHub branches when creating a pull request #3407

Open
hamidonos opened this issue Sep 4, 2024 · 0 comments
Open

Validate rules for GitHub branches when creating a pull request #3407

hamidonos opened this issue Sep 4, 2024 · 0 comments

Comments

@hamidonos
Copy link
Collaborator

Situation

We have a branch name convention which currently is not validated automatically.

Wanted

Configure the pipelines to validate the branch name. Invalid branch names should make the pipeline fail.

Solution

Something like this should do the trick.

jobs:
  check-branch-name:
    runs-on: ubuntu-latest

    steps:
      - name: Check branch name
        run: |
          BRANCH_NAME=${GITHUB_REF#refs/heads/}
          if [[ ! "$BRANCH_NAME" =~ ^(feature|bugfix|hotfix)/.+$ ]]; then
            echo "Branch name '$BRANCH_NAME' does not match the required pattern."
            exit 1
          fi

It might be desirable to put this into a blueprint which can be used across all GitHub workflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant