name: Close needs-info bug issues on: schedule: - cron: "17 6 * * *" # daily workflow_dispatch: {} permissions: issues: write jobs: close_stale: runs-on: ubuntu-latest steps: - name: Close inactive needs-info bug issues uses: actions/github-script@v7 with: script: | const owner = context.repo.owner; const repo = context.repo.repo; const NEEDS_INFO = "needs-info"; const CLOSE_AFTER_DAYS = 1; const closeMarker = ""; const now = Date.now(); const closeCutoff = now - CLOSE_AFTER_DAYS * 24 * 60 * 60 * 1000; async function listOpenNeedsInfoIssues() { const q = `repo:${owner}/${repo} is:issue is:open label:bug label:"${NEEDS_INFO}"`; return github.paginate(github.rest.search.issuesAndPullRequests, { q, per_page: 100 }); } const items = await listOpenNeedsInfoIssues(); for (const item of items) { const issue_number = item.number; const updatedAtMs = new Date(item.updated_at).getTime(); const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100, }); const hasClosedComment = comments.some(c => (c.body || "").includes(closeMarker)); if (updatedAtMs <= closeCutoff) { if (!hasClosedComment) { const body = `${closeMarker}\n` + `Closing this bug report since we didn't get the requested details within 1 day.\n\n` + `If you can share the missing info, reply here and we can reopen.`; await github.rest.issues.createComment({ owner, repo, issue_number, body }); } await github.rest.issues.update({ owner, repo, issue_number, state: "closed", state_reason: "not_planned", }); } }