Skip to content

LNK-2726: Implement checks for Jira key in PR title #23

LNK-2726: Implement checks for Jira key in PR title

LNK-2726: Implement checks for Jira key in PR title #23

Workflow file for this run

# From: https://levelup.gitconnected.com/enforcing-jira-ticket-formatting-in-github-pr-titles-and-commit-messages-78d9755568df
name: "PR Title Check"
on:
pull_request:
branches: [ LNK-2726-Enforce-Jira-key-in-PR-message ]
types: [opened, edited, synchronize]
jobs:
check-title:
runs-on: ubuntu-latest
steps:
- name: Check PR title
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const payload = context.payload
const prTitle = payload.pull_request.title
// The pattern for JIRA ticket format
const jiraPattern = /^LNK-\d+[:-]/g
if (!jiraPattern.test(prTitle)) {
console.log('Could not find a LNK Jira ticket in PR title!')
// Fails the workflow
core.setFailed('Could not find a LNK Jira ticket in PR title!')
} else {
console.log('PR title format is correct.')
}