forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
31 lines (28 loc) · 927 Bytes
/
pr-issue-check.yml
File metadata and controls
31 lines (28 loc) · 927 Bytes
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
name: PR issue check
on:
pull_request:
types:
- 'opened'
- 'reopened'
- 'synchronize'
- 'labeled'
- 'unlabeled'
permissions: {}
jobs:
check-for-attached-issue:
name: 'Check for attached issue'
runs-on: ubuntu-latest
steps:
- name: 'Ensure PR has an associated issue'
uses: actions/github-script@v8
with:
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
if (!labels.includes('skip-issue-check')) {
const prBody = context.payload.pull_request.body || '';
const issueLink = prBody.match(/https:\/\/github\.com\/\S+\/issues\/\d+/);
const issueReference = prBody.match(/#\d+/);
if (!issueLink && !issueReference) {
core.setFailed('No associated issue found in the PR description.');
}
}