MIJN-9884-feature/Conditionally set release note headers #2697
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from: https://levelup.gitconnected.com/enforcing-jira-ticket-formatting-in-github-pr-titles-and-commit-messages-78d9755568df | |
name: 'PR Title Check' | |
on: | |
pull_request: | |
types: [opened, edited, synchronize] | |
jobs: | |
check-title: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check PR title | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const payload = context.payload | |
const prTitle = payload.pull_request.title | |
// Titel moet beginnen met mijn-xxxx-chore/feature/bug! todo mijn- patroon moet weggehaald worden wanneer de workflows van mijn-7620 gemerged zijn | |
const jiraPattern = /^MIJN-\d+-(CHORE|FEATURE|BUG)/i | |
const dependabotPattern = /^Build\(deps(-dev)?\): bump/ | |
const disallowedQuotesPattern = /"/ | |
if (disallowedQuotesPattern.test(prTitle)) { | |
console.log('The PR title contains double quotes, which are not allowed!') | |
core.setFailed('PR title not valid. Please remove double quotes from the title.') | |
} else if (!(jiraPattern.test(prTitle) || dependabotPattern.test(prTitle))) { | |
console.log('The PR title does not match JIRA ticket format!') | |
core.setFailed('PR title not valid. Please make sure this PR uses the JIRA ticket or dependabot format.') | |
} else { | |
console.log('PR title format is correct.') | |
} |