Skip to content

GitHub Action that checks if the current branch name matches a specified regex pattern. This is particularly useful for enforcing branch naming conventions in your repositories.

License

Notifications You must be signed in to change notification settings

IamPekka058/branchMatchRegex

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

branchMatchRegex

GitHub release (latest by date) GitHub Workflow Status GitHub

branchMatchRegex is GitHub Action that checks if the current branch name matches a specified regex pattern. This is particularly useful for enforcing branch naming conventions in your repositories.

If you use useDefaultPatterns: true, see DEFAULT_PATTERNS.md for a detailed explanation of the default branch patterns.

Inputs

Name Description Required Default
regex The regex pattern to match the branch name against. No ""
path The path to the file containing the regex pattern. No ""
useDefaultPatterns Use default patterns for branch matching. No false
failOnUnmatchedRegex Fail the action if the branch does not match the regex pattern. No true
branchName The branch name to check against the regex pattern. No ${{ github.head_ref }}
useWildcard If true, treat patterns as simple wildcards (e.g. feature/*) instead of full regex. No false

Note: Either regex, path, or useDefaultPatterns must be provided. If both regex and path are provided, the path input takes precedence. You can't use useDefaultPatterns and path at the same time.

Example Usage

Below is an example of how to use the branchMatchRegex action in a GitHub workflow:

Example 1: Single Regex Pattern

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v0
  with:
    regex: 'feature/*'

Example 2: Inline list of Regex Patterns

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v0
  with:
    regex: "['feature/*', 'bugfix/*','hotfix/*']"

Example 3: List of Regex Patterns

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v0
  with:
    regex: |
        - 'feature/*'
        - 'bugfix/*'
        - 'hotfix/*'

Example 4: Regex Patterns from a File

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v0
  with:
    path: 'branch-regex-patterns.yml'

The branch-regex-patterns.yml file could look like this:

- 'feature/*'
- 'bugfix/*'
- 'hotfix/*'

Example 5: Use Default Patterns

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v0
  with:
    useDefaultPatterns: true

License

This project is licensed under the MIT License. See the LICENSE file for details.

Made with ❤️ in Bavaria

About

GitHub Action that checks if the current branch name matches a specified regex pattern. This is particularly useful for enforcing branch naming conventions in your repositories.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •