Skip to content

Commit c6a8a74

Browse files
committed
feat: add jira-check
1 parent 38eae82 commit c6a8a74

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: PR Jira Ticket Check
2+
3+
on:
4+
workflow_call:
5+
6+
# This allows a subsequently queued workflow run to interrupt previous runs
7+
concurrency:
8+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
9+
cancel-in-progress: true
10+
11+
jobs:
12+
jira-ticket-check:
13+
name: PR Jira Ticket
14+
runs-on: ubuntu-latest
15+
if: startsWith( github.repository, 'elementor/' )
16+
steps:
17+
- name: Check for Jira ticket
18+
uses: actions/github-script@v7
19+
with:
20+
script: |
21+
const pattern = /[A-Z]{2,10}-\d+/;
22+
23+
const title = context.payload.pull_request?.title || '';
24+
const branch = context.payload.pull_request?.head?.ref || '';
25+
const body = context.payload.pull_request?.body || '';
26+
27+
const sources = { title, branch, body };
28+
const found = Object.entries(sources).find(([, value]) => pattern.test(value));
29+
30+
if (found) {
31+
const [source, value] = found;
32+
const ticket = value.match(pattern)[0];
33+
core.info(`Found Jira ticket ${ticket} in PR ${source}`);
34+
} else {
35+
core.setFailed('No Jira ticket found in PR title, branch name, or body');
36+
}

0 commit comments

Comments
 (0)