Skip to content

Commit

Permalink
Add Github action to ensure PR's have an associated issue (#24616)
Browse files Browse the repository at this point in the history
closes #21934
  • Loading branch information
eleanorjboyd authored Dec 17, 2024
1 parent cbf8eee commit f5dfc7b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/pr-file-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ name: PR files
on:
pull_request:
types:
# On by default if you specify no types.
- 'opened'
- 'reopened'
- 'synchronize'
# For `skip-label` only.
- 'labeled'
- 'unlabeled'

Expand Down Expand Up @@ -42,3 +40,15 @@ jobs:
.github/test_plan.md
skip-label: 'skip tests'
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)'

- name: 'Ensure PR has an associated issue'
uses: actions/github-script@v6
with:
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
if (!labels.includes('skip-issue-check')) {
const issueLink = context.payload.pull_request.body.match(/https:\/\/github\.com\/\S+\/issues\/\d+/);
if (!issueLink) {
core.setFailed('No associated issue found in the PR description.');
}
}

0 comments on commit f5dfc7b

Please sign in to comment.