Skip to content

Remove the PR issue verification #2

Remove the PR issue verification

Remove the PR issue verification #2

name: Verify GitHub Issue Link
on:
pull_request:
branches:
- main
types: [opened, edited, synchronize, reopened]
jobs:
verify-issue-link:
name: Verify GitHub Issue Link
runs-on: ubuntu-latest
# Skip if source branch is production (merging production back)
if: github.head_ref != 'production'
steps:
- name: Verify Issue Link in PR
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
// Skip draft PRs
if (pr.draft) {
console.log("Draft PR does not have to have GitHub issue specified. Check passed.");
return;
}
// Skip dependency update PRs
if (/\[\w+\] Update dependencies from/.test(pr.title)) {
console.log("Dependency update PRs don't need release notes. Check passed.");
return;
}
// Skip automated PRs
if (/\[automated\]/.test(pr.title)) {
console.log("Automated PRs don't need release notes. Check passed.");
return;
}
// Skip Bump PRs (usually dependabot)
if (/Bump/.test(pr.title)) {
console.log("Automated PRs don't need release notes. Check passed.");
return;
}
const body = pr.body || '';
const issuePatterns = [
{ name: "GitHub Full Link", pattern: /github\.com\/dotnet\/(.+)\/issues\/(\d+)/ },
{ name: "AzDO DevOps Link", pattern: /dev\.azure\.com\/(.+)\/(.+)\/_workitems/ },
{ name: "AzDO Visual Studio Link", pattern: /(.+)\.visualstudio\.com\/(.+)\/_workitems/ },
{ name: "GitHub Issue Shortcut", pattern: /(?<!\w)([\w-]+\/[\w-]+)?#\d+\b/ }
];
let hasIssue = false;
for (const { name, pattern } of issuePatterns) {
if (pattern.test(body)) {
console.log(`Found issue link matching pattern: ${name}`);
hasIssue = true;
break;
}
}
if (!hasIssue) {
core.setFailed("Link to the corresponding GitHub/AzDO issue is missing in the PR description.");
}