From f5dfc7b74f596fc3c5248a8fce3aa521ca253b7b Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Mon, 16 Dec 2024 16:13:15 -0800 Subject: [PATCH] Add Github action to ensure PR's have an associated issue (#24616) closes https://github.com/microsoft/vscode-python/issues/21934 --- .github/workflows/pr-file-check.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index be55f4ad2f3b..4e32915955ea 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -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' @@ -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.'); + } + }