mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-17 15:32:01 +00:00
70 lines
2.8 KiB
YAML
70 lines
2.8 KiB
YAML
name: Close stale needs-info issues
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "17 6 * * *" # daily
|
|
workflow_dispatch: {}
|
|
|
|
permissions:
|
|
issues: write
|
|
|
|
jobs:
|
|
close_stale:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Warn then close inactive needs-info
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const owner = context.repo.owner;
|
|
const repo = context.repo.repo;
|
|
|
|
const NEEDS_INFO = "needs-info";
|
|
const WARN_AFTER_DAYS = 14;
|
|
const CLOSE_AFTER_DAYS = 21;
|
|
|
|
const warnMarker = "<!-- nuvio-bot:stale-warning -->";
|
|
const closeMarker = "<!-- nuvio-bot:stale-close -->";
|
|
|
|
const now = Date.now();
|
|
const warnCutoff = now - WARN_AFTER_DAYS * 24 * 60 * 60 * 1000;
|
|
const closeCutoff = now - CLOSE_AFTER_DAYS * 24 * 60 * 60 * 1000;
|
|
|
|
async function listOpenNeedsInfoIssues() {
|
|
const q = `repo:${owner}/${repo} is:issue is:open label:"${NEEDS_INFO}"`;
|
|
const res = await github.rest.search.issuesAndPullRequests({ q, per_page: 50 });
|
|
return res.data.items || [];
|
|
}
|
|
|
|
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 hasWarned = comments.some(c => (c.body || "").includes(warnMarker));
|
|
const hasClosedComment = comments.some(c => (c.body || "").includes(closeMarker));
|
|
|
|
if (updatedAtMs <= closeCutoff && hasWarned && !hasClosedComment) {
|
|
const body =
|
|
`${closeMarker}\n` +
|
|
`Closing this for now since we didn't get the requested details.\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" });
|
|
continue;
|
|
}
|
|
|
|
if (updatedAtMs <= warnCutoff && !hasWarned) {
|
|
const body =
|
|
`${warnMarker}\n` +
|
|
`Just a quick ping: this issue is labeled \`${NEEDS_INFO}\` and hasn't had any updates in a bit.\n\n` +
|
|
`If you can add the missing details, we can keep going. Otherwise it may be closed after a grace period.`;
|
|
await github.rest.issues.createComment({ owner, repo, issue_number, body });
|
|
}
|
|
}
|