はじめに
This tutorial demonstrates how to use the actions/stale action 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.
In the tutorial, you will first make a workflow file that uses the actions/stale action. Then, you will customize the workflow to suit your needs.
ワークフローの作成
-
このプロジェクト管理ワークフローを適用したいリポジトリを選択してください。 書き込みアクセス権を持つ既存のリポジトリを利用することも、新しいリポジトリを作成することもできます。 リポジトリの作成に関する詳細は「新しいリポジトリの作成」を参照してください。
-
リポジトリに、
.github/workflows/YOUR_WORKFLOW.ymlというファイルをYOUR_WORKFLOWの部分を選択した名前で置き換えて作成してください。 これがワークフローファイルです。 GitHub上での新しいファイルの作成に関する詳しい情報については「新しいファイルの作成」を参照してください。 -
Copy the following YAML contents into your workflow file.
YAML name: Close inactive issues on: schedule: - cron: "30 1 * * *" jobs: close-issues: runs-on: ubuntu-latest steps: - uses: actions/stale@v3 with: days-before-issue-stale: 30 days-before-issue-close: 14 stale-issue-label: "stale" stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." days-before-pr-stale: -1 days-before-pr-close: -1 repo-token: ${{ secrets.GITHUB_TOKEN }} -
Customize the parameters in your workflow file:
- Change the value for
on.scheduleto 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 "Scheduled events." - Change the value for
days-before-issue-staleto the number of days without activity before theactions/staleaction labels an issue. If you never want this action to label issues, set this value to-1. - Change the value for
days-before-issue-closeto the number of days without activity before theactions/staleaction closes an issue. If you never want this action to close issues, set this value to-1. - Change the value for
stale-issue-labelto the label that you want to apply to issues that have been inactive for the amount of time specified bydays-before-issue-stale. - Change the value for
stale-issue-messageto the comment that you want to add to issues that are labeled by theactions/staleaction. - Change the value for
close-issue-messageto the comment that you want to add to issues that are closed by theactions/staleaction.
- Change the value for
-
ワークフローファイルを、リポジトリのデフォルトブランチにコミットしてください。 詳細は「新しいファイルを作成する」を参照してください。
Expected results
Based 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.
ノート: scheduleイベントは、GitHub Actionsのワークフローの実行による高負荷の間、遅延させられることがあります。 高負荷の時間帯には、毎時の開始時点が含まれます。 遅延の可能性を減らすために、Ⅰ時間の中の別の時間帯に実行されるようワークフローをスケジューリングしてください。
You can view the history of your workflow runs to see this workflow run periodically. 詳しい情報については、「ワークフロー実行の履歴を表示する」を参照してください。
This workflow will only label and/or close 30 issues at a time in order to avoid rate limit abuse. You can configure this with the operations-per-run setting. For more information, see the actions/stale action documentation.
次のステップ
- To learn more about additional things you can do with the
actions/staleaction, like closing inactive pull requests, ignoring issues with certain labels or milestones, or only checking issues with certain labels, see theactions/staleaction documentation. - Search GitHub for examples of workflows using this action.

