From 119775b0883c4082fd62b504dde8742978c1df71 Mon Sep 17 00:00:00 2001 From: Miguel Arias Date: Thu, 7 Dec 2023 16:23:59 +0000 Subject: [PATCH] Adding pr-checks --- .github/workflows/pr-validator.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/pr-validator.yml diff --git a/.github/workflows/pr-validator.yml b/.github/workflows/pr-validator.yml new file mode 100644 index 0000000..b5a4c90 --- /dev/null +++ b/.github/workflows/pr-validator.yml @@ -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.') + } \ No newline at end of file