iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🌐
Automatically Close Inactive Issues with GitHub Actions
By using GitHub Actions' actions/stale, you can automatically close inactive issues.
- Closing inactive issues - GitHub Docs
- actions/stale: Marks issues and pull requests that have not had recent interaction
The flow with actions/stale is as follows:
- Comment on an issue that has been inactive for a certain period to encourage action from participants.
- Close the issue if there is no further activity after another certain period.
I will now try implementing this in my own project.
Configuration
I added a workflow to the repository with a file named .github/workflows/stale-issues.yml.
name: Close inactive issues
on:
schedule:
- cron: "30 1 * * *"
jobs:
close-issues:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue is stale because it has been open for 60 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
stale-issue-label: "stale"
exempt-issue-labels: 'bug,enhancement'
days-before-issue-stale: 60
days-before-issue-close: 14
days-before-pr-stale: -1
days-before-pr-close: -1
Below is an explanation of each item:
-
on.schedule.cronspecifies the execution date and time. Setting it to"30 1 * * *"means it will run every day at 1:30 (UTC). - If there is no activity for the number of days specified in
days-before-issue-stale, it will add the label specified instale-issue-labeland post thestale-issue-messageas a comment.- Issues with labels specified in
exempt-issue-labelswill be excluded.
- Issues with labels specified in
- If there is still no activity for the number of days specified in
days-before-issue-close, the ticket will be closed and theclose-issue-messagewill be posted as a comment. - While
actions/stalecan also close Pull Requests, I have excluded Pull Requests this time by settingdays-before-pr-staleanddays-before-pr-closeto-1.
Results
They were processed in sequence as shown below (at the time of introduction, labels were set for those over 60 days, and then closed 14 days later):

Conclusion
Closing neglected issues one by one was a hassle, so being able to close them all at once was a huge help.
I think it's also great for my peace of mind to be able to handle inactive issues mechanically from now on.
Discussion