Skip to content

Stale Issue Detection #13

Stale Issue Detection

Stale Issue Detection #13

Workflow file for this run

name: Stale Issue Detection
on:
schedule:
- cron: '0 10 * * 2,5' # Tuesday & Friday at 10 AM UTC
jobs:
check-stale:
runs-on: ubuntu-latest
steps:
- name: Flag stale in-progress issues
uses: actions/github-script@v7
with:
script: |
const fiveDaysAgo = new Date();
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 5);
// Get all open issues
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
sort: 'updated',
direction: 'asc',
per_page: 100
});
// Filter to issues assigned (in progress) but not updated recently
const stale = issues.filter(i => {
if (!i.assignee) return false;
const updated = new Date(i.updated_at);
return updated < fiveDaysAgo;
});
for (const issue of stale.slice(0, 10)) {
const hasLabel = issue.labels.some(l => l.name === 'stale');
if (hasLabel) continue;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['stale']
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `🕐 **Stale check:** This issue is assigned but hasn't been updated in 5+ days.\n\n- Still working on it? Post a quick status update.\n- Blocked? Add the \`blocked\` label and describe the blocker.\n- Moved on? Unassign yourself.\n\n*Remove the \`stale\` label when you respond. Auto-generated by stale-check workflow.*`
});
}
console.log(`Flagged ${Math.min(stale.length, 10)} stale issues`);