{"meta":{"title":"Closing inactive issues","intro":"You can use GitHub Actions to comment on or close issues that have been inactive for a certain period of time.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/actions","title":"GitHub Actions"},{"href":"/en/actions/tutorials","title":"Tutorials"},{"href":"/en/actions/tutorials/manage-your-work","title":"Manage your work"},{"href":"/en/actions/tutorials/manage-your-work/close-inactive-issues","title":"Close inactive issues"}],"documentType":"article"},"body":"# Closing inactive issues\n\nYou can use GitHub Actions to comment on or close issues that have been inactive for a certain period of time.\n\n## Introduction\n\nThis tutorial demonstrates how to use the [`actions/stale` action](https://github.com/marketplace/actions/close-stale-issues) to comment on and close issues that have been inactive for a certain period of time. For example, you can comment if an issue has been inactive for 30 days to prompt participants to take action. Then, if no additional activity occurs after 14 days, you can close the issue.\n\nIn the tutorial, you will first make a workflow file that uses the [`actions/stale` action](https://github.com/marketplace/actions/close-stale-issues). Then, you will customize the workflow to suit your needs.\n\n## Creating the workflow\n\n1. Choose a repository where you want to apply this project management workflow. You can use an existing repository that you have write access to, or you can create a new repository. For more information about creating a repository, see [Creating a new repository](/en/repositories/creating-and-managing-repositories/creating-a-new-repository).\n\n2. In your repository, create a file called `.github/workflows/YOUR_WORKFLOW.yml`, replacing `YOUR_WORKFLOW` with a name of your choice. This is a workflow file. For more information about creating new files on GitHub, see [Creating new files](/en/repositories/working-with-files/managing-files/creating-new-files).\n\n3. Copy the following YAML contents into your workflow file.\n\n   ```yaml copy\n   name: Close inactive issues\n   on:\n     schedule:\n       - cron: \"30 1 * * *\"\n\n   jobs:\n     close-issues:\n       runs-on: ubuntu-latest\n       permissions:\n         issues: write\n         pull-requests: write\n       steps:\n         - uses: actions/stale@v10\n           with:\n             days-before-issue-stale: 30\n             days-before-issue-close: 14\n             stale-issue-label: \"stale\"\n             stale-issue-message: \"This issue is stale because it has been open for 30 days with no activity.\"\n             close-issue-message: \"This issue was closed because it has been inactive for 14 days since being marked as stale.\"\n             days-before-pr-stale: -1\n             days-before-pr-close: -1\n             repo-token: ${{ secrets.GITHUB_TOKEN }}\n   ```\n\n4. Customize the parameters in your workflow file:\n   * Change the value for `on.schedule` to dictate when you want this workflow to run. In the example above, the workflow will run every day at 1:30 UTC. For more information about scheduled workflows, see [Events that trigger workflows](/en/actions/using-workflows/events-that-trigger-workflows#scheduled-events).\n   * Change the value for `days-before-issue-stale` to the number of days without activity before the `actions/stale` action labels an issue. If you never want this action to label issues, set this value to `-1`.\n   * Change the value for `days-before-issue-close` to the number of days without activity before the `actions/stale` action closes an issue. If you never want this action to close issues, set this value to `-1`.\n   * Change the value for `stale-issue-label` to the label that you want to apply to issues that have been inactive for the amount of time specified by `days-before-issue-stale`.\n   * Change the value for `stale-issue-message` to the comment that you want to add to issues that are labeled by the `actions/stale` action.\n   * Change the value for `close-issue-message` to the comment that you want to add to issues that are closed by the `actions/stale` action.\n\n5. Commit your workflow file to the default branch of your repository. For more information, see [Creating new files](/en/repositories/working-with-files/managing-files/creating-new-files).\n\n## Expected results\n\nBased on the `schedule` parameter (for example, every day at 1:30 UTC), your workflow will find issues that have been inactive for the specified period of time and will add the specified comment and label. Additionally, your workflow will close any previously labeled issues if no additional activity has occurred for the specified period of time.\n\n> \\[!NOTE]\n> The `schedule` event can be delayed during periods of high loads of GitHub Actions workflow runs. High load times include the start of every hour. If the load is sufficiently high enough, some queued jobs may be dropped. To decrease the chance of delay, schedule your workflow to run at a different time of the hour.\n\nYou can view the history of your workflow runs to see this workflow run periodically. For more information, see [Viewing workflow run history](/en/actions/monitoring-and-troubleshooting-workflows/viewing-workflow-run-history).\n\nThis workflow will only label and/or close 30 issues at a time in order to avoid exceeding a rate limit. You can configure this with the `operations-per-run` setting. For more information, see the [`actions/stale` action documentation](https://github.com/marketplace/actions/close-stale-issues).\n\n## Next steps\n\n* To learn more about additional things you can do with the `actions/stale` action, like closing inactive pull requests, ignoring issues with certain labels or milestones, or only checking issues with certain labels, see the [`actions/stale` action documentation](https://github.com/marketplace/actions/close-stale-issues).\n* [Search GitHub](https://github.com/search?q=%22uses%3A+actions%2Fstale%22\\&type=code) for examples of workflows using this action."}