Skip to content

chore(deps): bump urllib3 from 2.6.3 to 2.7.0 in /.github #987

chore(deps): bump urllib3 from 2.6.3 to 2.7.0 in /.github

chore(deps): bump urllib3 from 2.6.3 to 2.7.0 in /.github #987

# This workflow will inspect a pull request to ensure there is a linked issue or a
# valid issue is mentioned in the body. If neither is present it fails the check and adds
# a comment alerting users of this missing requirement.
#
# Uses pull_request_target so fork PRs get a write-scoped token for the
# comment. Do NOT add actions/checkout or execute anything from the PR head
# in this file: the safety of pull_request_target relies on the job reading
# only PR metadata via the API.
name: VerifyIssue
on:
pull_request_target:
branches-ignore:
- 'renovate/**'
types:
- edited
- synchronize
- opened
- reopened
- labeled
- unlabeled
permissions: read-all
concurrency:
group: verify-linked-issue-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
verify_linked_issue:
runs-on: ubuntu-latest
name: Ensure Pull Request has a linked issue.
permissions:
issues: write
pull-requests: write
steps:
- name: Verify Linked Issue
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const marker = '<!-- verify-linked-issue -->';
const body = context.payload.pull_request.body || '';
const hasNoIssueLabel = (context.payload.pull_request.labels || [])
.some((l) => l.name === 'no-issue');
core.debug(`Checking PR body: "${body}"`);
// Match a GitHub-style issue reference preceded by a linking keyword
// at the start of a line, e.g. "Closes #123" or "Fixes owner/repo#45".
const keywords = 'close[sd]?|fix(?:es|ed)?|resolve[sd]?|refs?|refers?|see';
const name = '[\\w.-]+';
const pattern = [
'^\\s*', // start of line, optional indent
`(?:${keywords})\\b`, // keyword (case-insensitive via flag)
'[:\\s]+', // colon and/or whitespace
`(?:(${name})\\/(${name}))?`, // optional owner/repo prefix
'#(\\d+)', // issue number
].join('');
const re = new RegExp(pattern, 'gim');
let linked = false;
for (const m of hasNoIssueLabel ? [] : body.matchAll(re)) {
const owner = m[1] || context.repo.owner;
const repo = m[2] || context.repo.repo;
const issueNumber = parseInt(m[3], 10);
try {
await github.rest.issues.get({
owner,
repo,
issue_number: issueNumber,
});
core.notice(`Success! Linked issue ${owner}/${repo}#${issueNumber} found in body.`);
linked = true;
break;
} catch {
core.debug(`${owner}/${repo}#${issueNumber} is not a valid issue.`);
}
}
let existing = [];
try {
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
per_page: 100,
});
existing = comments.filter(
(c) => c.user.login === 'github-actions[bot]' && c.body.includes(marker),
);
} catch (err) {
core.warning(`Could not list PR comments: ${err.message}`);
}
if (linked || hasNoIssueLabel) {
for (const c of existing) {
try {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: c.id,
});
} catch (err) {
core.warning(`Could not delete stale comment ${c.id}: ${err.message}`);
}
}
return;
}
if (existing.length === 0) {
const message = [
marker,
'',
'> [!WARNING]',
'> **Linked issue missing.**',
'>',
'> Reference one in the PR body using a keyword (Closes / Fixes / Resolves / Refs / See) followed by `#<issue_id>` or `owner/repo#<issue_id>`.',
'>',
'> Alternatively, apply the `no-issue` label to skip this check.',
].join('\n');
try {
await github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message,
});
} catch (err) {
core.warning(`Could not post linked-issue warning comment: ${err.message}`);
}
}
core.setFailed('No Linked Issue Found!');