-
Notifications
You must be signed in to change notification settings - Fork 10
50 lines (43 loc) · 1.95 KB
/
Copy pathverify-linked-issue.yaml
File metadata and controls
50 lines (43 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# This repository is public and cannot call reusable workflows from a private
# repository (regulaforensics/reusable-workflows). The logic below is a local
# copy that mirrors the reusable workflow exactly. SHA pins are kept up-to-date
# by Renovate (see renovate.json).
name: Verify Issue
on:
pull_request:
types: [edited, synchronize, opened, reopened]
jobs:
verify_linked_issue:
runs-on: ubuntu-latest
name: PR has a linked issue.
steps:
- name: Verify Linked Issue
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const skipBranchPattern = '';
const issueUrlPattern = 'https://redmine.regulaforensics.com/';
const clickupUrlPattern = 'https://app.clickup.com/';
const pr = context.payload.pull_request;
if (skipBranchPattern && pr.head.ref.startsWith(skipBranchPattern)) {
console.log(`Skipping verification — branch "${pr.head.ref}" matches skip pattern "${skipBranchPattern}".`);
return;
}
if (!pr.body) {
console.log("No Linked Issue Found!");
core.setFailed('No linked issue found in the pull request description.');
return;
}
const hasRedmineIssue = issueUrlPattern && pr.body.includes(issueUrlPattern);
const hasClickupIssue = clickupUrlPattern && pr.body.includes(clickupUrlPattern);
if (!hasRedmineIssue && !hasClickupIssue) {
console.log("No Linked Issue Found!");
core.setFailed('No linked issue found in the pull request description.');
return;
}
if (hasRedmineIssue) {
console.log(`Linked issue found matching pattern "${issueUrlPattern}".`);
}
if (hasClickupIssue) {
console.log(`Linked issue found matching pattern "${clickupUrlPattern}".`);
}