File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ name : PR Jira Ticket Check
2+ description : Validates that a Jira ticket (e.g. ED-1234) exists in the PR title, branch name, or body.
3+
4+ runs :
5+ using : composite
6+ steps :
7+ - name : Check for Jira ticket
8+ uses : actions/github-script@v7
9+ with :
10+ script : |
11+ const pattern = /[A-Z]{2,10}-\d+/;
12+
13+ const title = context.payload.pull_request?.title || '';
14+ const branch = context.payload.pull_request?.head?.ref || '';
15+ const body = context.payload.pull_request?.body || '';
16+
17+ const sources = { title, branch, body };
18+ const found = Object.entries(sources).find(([, value]) => pattern.test(value));
19+
20+ if (found) {
21+ const [source, value] = found;
22+ const ticket = value.match(pattern)[0];
23+ core.info(`Found Jira ticket ${ticket} in PR ${source}`);
24+ } else {
25+ core.setFailed('No Jira ticket found in PR title, branch name, or body');
26+ }
You can’t perform that action at this time.
0 commit comments