Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/pr-title-jira-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ jobs:
github.event.pull_request.draft == false"
runs-on: gh-2-core-ubuntu-latest
steps:
- env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
PATTERN='https://paypal\.atlassian\.net/browse/[A-Z]+-[0-9]+'
if echo "$PR_BODY" | grep -qE "$PATTERN"; then
echo "Jira ticket found"
else
echo "::error::Missing Jira ticket link in PR body. Include the full Jira ticket link:"
echo " | [Jira ticket](https://paypal.atlassian.net/browse/DTBTWEB-123) |"
exit 1
fi
- uses: braintree/web-sdk-github-actions/actions/check-jira-reference@main
with:
pr-body: ${{ github.event.pull_request.body }}
jira-url-pattern: ${{ inputs.jira-url-pattern }}
21 changes: 21 additions & 0 deletions actions/check-jira-reference/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Check Jira Reference"
description: "Fails if the PR body does not contain a Jira ticket link"

inputs:
pr-body:
description: "The pull request body to check"
required: true
jira-url-pattern:
description: "Regex pattern a Jira ticket URL must match"
required: false
default: 'https://paypal\.atlassian\.net/browse/[A-Z]+-[0-9]+'

runs:
using: "composite"
steps:
- name: "Check for Jira ticket reference"
run: node '${{ github.action_path }}/../../dist/check-jira-reference.js'
shell: bash
env:
PR_BODY: ${{ inputs.pr-body }}
JIRA_PATTERN: ${{ inputs.jira-url-pattern }}
Comment on lines +16 to +21
2 changes: 1 addition & 1 deletion build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ if (entries.length === 0) {
}

execSync(
`npx esbuild ${entries.join(' ')} --bundle --platform=node --outdir=dist --target=node24`,
`npx esbuild ${entries.join(' ')} --bundle --platform=node --outdir=dist --target=node24 --minify`,
{ stdio: 'inherit' }
);
149 changes: 149 additions & 0 deletions dist/check-jira-reference.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/check-jira-reference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as core from '@actions/core';
import { getRequiredEnv } from './utils';

const prBody = process.env.PR_BODY ?? '';
const jiraPattern = getRequiredEnv('JIRA_PATTERN');

const regex = new RegExp(jiraPattern);

if (!regex.test(prBody)) {
core.setFailed(
'Missing Jira ticket link in PR body. Include the full Jira ticket link:\n' +
' | [Jira ticket](https://paypal.atlassian.net/browse/DTBTWEB-123) |'
);
}