feat: incorporate jira link check into pr-title-check action #1
Workflow file for this run
This file contains hidden or 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
| name: 'Check Jira Link in PR' | |
| on: | |
| pull_request: | |
| types: [opened, edited, reopened, synchronize] | |
| jobs: | |
| check_jira_link: | |
| runs-on: linux-arm64 | |
| steps: | |
| - name: Check for Jira link in PR description | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 | |
| with: | |
| script: | | |
| const prBody = context.payload.pull_request.body || ''; | |
| const prTitle = context.payload.pull_request.title || ''; | |
| const branchName = context.payload.pull_request.head.ref || ''; | |
| const prAuthor = context.payload.pull_request.user.login || ''; | |
| // Skip validation for automated PRs (Renovate, Dependabot, etc.) | |
| const automatedBots = ['renovate[bot]', 'dependabot[bot]']; | |
| if (automatedBots.includes(prAuthor)) { | |
| core.info(`✅ Automated PR from ${prAuthor} - skipping Jira link validation`); | |
| return; | |
| } | |
| // Check if "nojira" or "no-jira" is present in branch name, title, or description (case-insensitive) | |
| const noJiraPattern = /no-?jira/i; | |
| const hasNoJira = noJiraPattern.test(branchName) || | |
| noJiraPattern.test(prTitle) || | |
| noJiraPattern.test(prBody); | |
| if (hasNoJira) { | |
| core.info('✅ "nojira"/"no-jira" found - skipping Jira link validation'); | |
| return; | |
| } | |
| // Check for Jira link | |
| const jiraLinkPattern = /https:\/\/montaapp\.atlassian\.net\/browse\/[A-Z]+-\d+/; | |
| if (!jiraLinkPattern.test(prBody)) { | |
| core.setFailed('❌ No Jira ticket link found in PR description.\n\n' + | |
| 'Please add a link to your Jira ticket in the format:\n' + | |
| 'https://montaapp.atlassian.net/browse/PROJECT-123\n\n' + | |
| 'Example: https://montaapp.atlassian.net/browse/CPONETOPS-568\n\n' + | |
| 'To skip this check, include "nojira" or "no-jira" in the branch name, PR title, or description.'); | |
| } else { | |
| const match = prBody.match(jiraLinkPattern); | |
| core.info(`✅ Found Jira ticket: ${match[0]}`); | |
| } |