Skip to content

Commit f5dfc7b

Browse files
authored
Add Github action to ensure PR's have an associated issue (#24616)
closes #21934
1 parent cbf8eee commit f5dfc7b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/pr-file-check.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ name: PR files
33
on:
44
pull_request:
55
types:
6-
# On by default if you specify no types.
76
- 'opened'
87
- 'reopened'
98
- 'synchronize'
10-
# For `skip-label` only.
119
- 'labeled'
1210
- 'unlabeled'
1311

@@ -42,3 +40,15 @@ jobs:
4240
.github/test_plan.md
4341
skip-label: 'skip tests'
4442
failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)'
43+
44+
- name: 'Ensure PR has an associated issue'
45+
uses: actions/github-script@v6
46+
with:
47+
script: |
48+
const labels = context.payload.pull_request.labels.map(label => label.name);
49+
if (!labels.includes('skip-issue-check')) {
50+
const issueLink = context.payload.pull_request.body.match(/https:\/\/github\.com\/\S+\/issues\/\d+/);
51+
if (!issueLink) {
52+
core.setFailed('No associated issue found in the PR description.');
53+
}
54+
}

0 commit comments

Comments
 (0)