7
2

More than 3 years have passed since last update.

GitHubの古くなったIssueを自動で閉じる

Posted at

目的

GitHubのIssueは古いものが残りがちなので、古くなったIssueを自動でクローズしたい。

Stale

Staleを利用すると、放置されたissueを自動的に閉じることができます。

以下のようにgithub-actionsのbotがstaleします。(動作確認用にすぐにstaleとcloseされるようにしています)

インストール手順

GitHubのリポジトリのActionsタブから、テンプレートを作成できます。

画面の下の方の Automate every step in your process 以下にStaleが存在します。

Set up this workflow のボタンを押すと、テンプレート作成画面に遷移します。

デフォルトで60日でstale、7日でstaleされたissueがcloseされます。

オプションで各種設定を変更することが可能です。
例えば、staleまで30日、closeまで5日に変更したい場合は以下のように記載します。

github/workflows/stale.yml
name: Mark stale issues and pull requests

on:
  schedule:
  - cron: "30 1 * * *"

jobs:
  stale:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/stale@v3
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        stale-issue-message: 'Stale issue message'
        stale-pr-message: 'Stale pull request message'
        stale-issue-label: 'no-issue-activity'
        stale-pr-label: 'no-pr-activity'
        days-before-stale: 30
        days-before-close: 5

その他の設定は、リポジトリのREADME.mdに記載されています。

7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2