Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/auto-close-missing-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ jobs:
if (!labelEvent) continue;
if (new Date(labelEvent.created_at) > fourDaysAgo) continue;

// Re-fetch the PR's current state to guard against race conditions:
// the label may have been removed between the initial paginated query
// and this point in the loop.
const currentPr = await github.rest.pulls.get({
owner,
repo,
pull_number: pr.number,
});

if (currentPr.data.state !== 'open') continue;

const currentLabels = currentPr.data.labels.map(l => l.name);
if (!currentLabels.includes('missing-issue')) continue;

const linkedIssuePattern = /\b(closes|close|fixes|fix|resolves|resolve|refs|ref|references)\s+(?:[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+)?#\d+/i;
if (linkedIssuePattern.test(currentPr.data.body || '')) continue;

await github.rest.pulls.update({
owner,
repo,
Expand Down
Loading