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.
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
, oruseDefaultPatterns
must be provided. If bothregex
andpath
are provided, thepath
input takes precedence. You can't useuseDefaultPatterns
andpath
at the same time.
Below is an example of how to use the branchMatchRegex
action in a GitHub workflow:
- name: Run branchMatchRegex action
uses: IamPekka058/branchMatchRegex@v0
with:
regex: 'feature/*'
- name: Run branchMatchRegex action
uses: IamPekka058/branchMatchRegex@v0
with:
regex: "['feature/*', 'bugfix/*','hotfix/*']"
- name: Run branchMatchRegex action
uses: IamPekka058/branchMatchRegex@v0
with:
regex: |
- 'feature/*'
- 'bugfix/*'
- 'hotfix/*'
- 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/*'
- name: Run branchMatchRegex action
uses: IamPekka058/branchMatchRegex@v0
with:
useDefaultPatterns: true
This project is licensed under the MIT License. See the LICENSE file for details.