Skip to content

Commit 05bb4c0

Browse files
flow-techMiguel Arias
andauthored
Adding pr-checks (#22)
Co-authored-by: Miguel Arias <miguelarias@Miguels-MacBook-Pro-2.localdomain>
1 parent 17303f4 commit 05bb4c0

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.github/pr-validator.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "PR Title Check"
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize]
5+
jobs:
6+
check-title:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check PR title
10+
uses: actions/github-script@v4
11+
with:
12+
github-token: ${{ secrets.GITHUB_TOKEN }}
13+
script: |
14+
const payload = context.payload
15+
const prTitle = payload.pull_request.title
16+
// The pattern for JIRA ticket format
17+
const jiraPattern = /([A-Z]+-\d+)|(breakglass)/gi;
18+
if (!jiraPattern.test(prTitle)) {
19+
console.log('The PR title does not match JIRA ticket format!')
20+
// Fails the workflow
21+
core.setFailed('PR title does not match JIRA ticket format!')
22+
} else {
23+
console.log('PR title format is correct.')
24+
}

0 commit comments

Comments
 (0)