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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

branchMatchRegex

Coverage GitHub release (latest by date) GitHub Workflow Status GitHub

What's new in v2?

  • All pattern sources (patterns, useDefaultPatterns, path) are now combined (cumulative), not mutually exclusive.
  • Input names have changed: use patterns instead of regex, and useWildcardPatterns instead of useWildcard.
  • You can now combine inline patterns, default patterns, and file/URL patterns in any combination.
  • The project is now based on TypeScript instead of plain JavaScript for improved type safety and maintainability.
  • Tests have been added (see the __tests__ directory) to ensure reliability and robustness.

branchMatchRegex is a GitHub Action that checks if the current branch name matches one or more specified patterns (regex or wildcard). This is especially 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
patterns The (regex or wildcard) patterns to match against the branch. Multiple patterns, one per line. No ""
path Path or URL to a file containing patterns (one per line). No ""
useDefaultPatterns Additionally use default patterns. See DEFAULT_PATTERNS.md. No false
failOnUnmatchedPattern Fail the action if the branch does not match any pattern. No true
useWildcardPatterns Treat patterns as wildcards (e.g. feature/*) instead of regex. No false
branch The branch to check. Yes ${{ github.head_ref }}

Note: All specified pattern sources (patterns, useDefaultPatterns, path) are combined. The order is: patterns, then default patterns, then file/URL. You can use any combination of sources at the same time.

Tip: The patterns input supports both plain lists and YAML-style lists. For example, both of the following are valid:

patterns: |
  feature/*
  fix/*

or

patterns: |
  - feature/*
  - fix/*

Example Usage

Example 1: Single inline pattern

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v2
  with:
    patterns: 'feature/.*'

Example 2: Multiple inline patterns (one per line)

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v2
  with:
    patterns: |
      feature/.*
      bugfix/.*
      hotfix/.*

Example 3: Patterns from a file

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

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

- feature/.*
- bugfix/.*
- hotfix/.*

Example 4: Use default patterns additionally

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

Example 5: Combine multiple sources

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v2
  with:
    patterns: |
      feature/.*
      bugfix/.*
    useDefaultPatterns: true
    path: 'branch-patterns.yml'

Example 6: Use wildcard patterns

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v2
  with:
    patterns: |
      feature/*
      bugfix/*
    useWildcardPatterns: true

Example 7: Patterns from a URL

- name: Run branchMatchRegex action
  uses: IamPekka058/branchMatchRegex@v2
  with:
    path: 'https://example.com/patterns.yml'

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 3

  •  
  •  
  •