Skip to content

Commit 2e90a4d

Browse files
authored
Stale old issues (12+ months of inactivity) and close them if no activity after 14 days (#5227)
Related to #5207 As discussed on the Spec call, closing old issues with no activity can be the first step and we can implement additional improvements (AI-assisted triage, better communication as proposed in #5208) independently. ## Changes - Stale issues after ~1 year of inactivity, Totally open to a different range - Close after 14 days after issue is stalled - automatically reopen issue if author, org member, or a collaborator posts "/reopen" comment on the issue. Open to relax to allow anyone to reopen Once #5208 is finalized, we can add a link to new contrib.md section from the message in workflow
1 parent ec0239c commit 2e90a4d

2 files changed

Lines changed: 51 additions & 5 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Reopen issue on command"
2+
on:
3+
issue_comment:
4+
types: [created]
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
reopen:
11+
# Only run on issues (not PRs), on closed issues, when the comment is exactly "/reopen",
12+
# and only if the commenter is the issue author or a member/collaborator/owner/contributor.
13+
if: >
14+
!github.event.issue.pull_request &&
15+
github.event.issue.state == 'closed' &&
16+
startsWith(github.event.comment.body, '/reopen') &&
17+
(
18+
github.event.comment.user.login == github.event.issue.user.login ||
19+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.comment.author_association)
20+
)
21+
permissions:
22+
issues: write # required to reopen the issue
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Reopen issue
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
REPO: ${{ github.repository }}
29+
ISSUE_NUMBER: ${{ github.event.issue.number }}
30+
COMMENT_BODY: ${{ github.event.comment.body }}
31+
run: |
32+
# Require the comment to be exactly "/reopen" (ignoring trailing whitespace)
33+
if [[ ! "$COMMENT_BODY" =~ ^/reopen[[:space:]]*$ ]]; then
34+
echo "Comment is not an exact /reopen command; skipping."
35+
exit 0
36+
fi
37+
gh issue reopen "$ISSUE_NUMBER" --repo "$REPO"
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Close stale pull requests"
1+
name: "Close stale pull requests and issues"
22
on:
33
schedule:
44
- cron: "12 3 * * *" # arbitrary time not to DDOS GitHub
@@ -10,6 +10,7 @@ jobs:
1010
stale:
1111
permissions:
1212
pull-requests: write # required for marking and closing stale PRs
13+
issues: write # required for marking and closing stale issues
1314
actions: write # required for the stale action to manage (reset) its state cache
1415
runs-on: ubuntu-latest
1516
steps:
@@ -19,9 +20,17 @@ jobs:
1920
stale-pr-message: 'This PR was marked stale. It will be closed in 14 days without additional activity.'
2021
close-pr-message: 'Closed as inactive. Feel free to reopen if this PR is still being worked on.'
2122
exempt-pr-labels: 'release:after-ga'
22-
# opt out of defaults to avoid marking issues as stale
23-
days-before-stale: -1
24-
days-before-close: -1
25-
# overrides the above only for pull requests
23+
stale-issue-message: 'This issue was marked stale due to lack of activity. Please leave a comment if you would like to keep this issue open.'
24+
close-issue-message: |
25+
Closed due to inactivity.
26+
27+
We appreciate your input, and if this issue is still relevant,
28+
please reopen it, or comment "/reopen" and we'll do it for you.
29+
30+
Thank you for your contribution!
31+
# applies only to pull requests
2632
days-before-pr-stale: 14
2733
days-before-pr-close: 14
34+
# applies only to issues
35+
days-before-issue-stale: 365
36+
days-before-issue-close: 14

0 commit comments

Comments
 (0)