Skip to content

Commit cef985d

Browse files
committed
Add Github action to ensure PR's have an associated issue
1 parent 567ca5a commit cef985d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,15 @@ jobs:
4242
.github/test_plan.md
4343
skip-label: 'skip tests'
4444
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)'
45+
46+
- name: 'Ensure PR has an associated issue'
47+
uses: actions/github-script@v6
48+
with:
49+
script: |
50+
const labels = context.payload.pull_request.labels.map(label => label.name);
51+
if (!labels.includes('skip-issue-check')) {
52+
const issueNumber = context.payload.pull_request.body.match(/#(\d+)/);
53+
if (!issueNumber) {
54+
core.setFailed('No associated issue found in the PR description.');
55+
}
56+
}

0 commit comments

Comments
 (0)