This action analyses the titles of Pull Requests to ensure they start with a Jira Issue Key. Issue Keys are a combination of a Project Key, a hyphen, and a number designating which issue it is. In general, Project Keys are two capital letters but Jira does allow for custom Project Keys and this issue attempts to abide by the custom format.
For example, if your project key were AB
then the following would be allowed
AB-1 Initialize Project
However, the following examples would not be allowed
aB-1 Initialize Project
ab-1 Initialize Project
Ab 1 Initialize Project
Valid Pull Request titles must also include a short description after the Issue Key. Therefore the following is not valid.
AB-1
Specifying a separator allows for using characters such as :
, -
or _
to be between the Jira key and title.
As an example with the separator :
the following is allowed
AB-1:Initialize Project
Note that by specifying a separator the following would not be allowed
AB-1: Initialize Project
By default this action checks that the Jira Project Key is at the start of the title string. To allow for the Jira Project
Key to be anywhere in the title set the keyAnywhereInTitle
property to true
. With this property enabled and the project
key set to AB
the following title is valid
Other: AB-1 Initialize Project
By default, this action will allow any valid Issue Key so long as it could be valid. If you want to be specific to your project, use the projectKey
input for the action.
A specific Project Key to always check for
Multiple Project Keys to always check for
A specific separator to use. Defaults to a space character.
Allows the Jira Project Key, Issue # and separator to be anywhere in the title. Defaults to false.
Note that projectKey
and projectKeys
works same under the hood. You can pass either one of them depending on the usecase.
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/enforce-pr-title-style-action@v2.1.2
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/enforce-pr-title-style-action@v2.1.2
with:
projectKey: 'AB'
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/enforce-pr-title-style-action@v2.1.2
with:
projectKeys: |
'AB'
'CD'
'EF'
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/enforce-pr-title-style-action@v2.1.2
with:
projectKey: 'AB'
separator: ':'
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/enforce-pr-title-style-action@v2.1.2
with:
projectKey: 'AB'
keyAnywhereInTitle: 'true'
Note that edits to a pull request title will not include the updated title as an input to this action
without specifying the edited
type. See the pull_request
event trigger documentation for more details. Thanks to @jdonboch for pointing this out.