Skip to content

Commit

Permalink
Adding pr-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Arias authored and Miguel Arias committed Dec 7, 2023
1 parent cbd4bee commit 9ed6855
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pr-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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@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 = /[A-Z]+-\d+/g
if (!jiraPattern.test(prTitle)) {
console.log('The PR title does not match JIRA ticket format!')
// Fails the workflow
core.setFailed('PR title does not match JIRA ticket format!')
} else {
console.log('PR title format is correct.')
}

0 comments on commit 9ed6855

Please sign in to comment.