diff --git a/actions/pr-jira-ticket/action.yml b/actions/pr-jira-ticket/action.yml new file mode 100644 index 0000000000..0871a066e6 --- /dev/null +++ b/actions/pr-jira-ticket/action.yml @@ -0,0 +1,26 @@ +name: PR Jira Ticket Check +description: Validates that a Jira ticket (e.g. ED-1234) exists in the PR title, branch name, or body. + +runs: + using: composite + steps: + - name: Check for Jira ticket + uses: actions/github-script@v7 + with: + script: | + const pattern = /[A-Z]{2,10}-\d+/; + + const title = context.payload.pull_request?.title || ''; + const branch = context.payload.pull_request?.head?.ref || ''; + const body = context.payload.pull_request?.body || ''; + + const sources = { title, branch, body }; + const found = Object.entries(sources).find(([, value]) => pattern.test(value)); + + if (found) { + const [source, value] = found; + const ticket = value.match(pattern)[0]; + core.info(`Found Jira ticket ${ticket} in PR ${source}`); + } else { + core.setFailed('No Jira ticket found in PR title, branch name, or body'); + }