LoginSignup
20
7

More than 3 years have passed since last update.

特定のラベルをセットした Issue を自動的に GitHub Projects のカラムに追加する

Last updated at Posted at 2019-09-04

2019/09/28 追記:
PROJ A ラベルがすでに設定されている Issue で別のラベルを追加した際も To do カラムに移動されてしまう問題があったので例を修正しました。


Project への追加自体は以下の Action を使えば簡単にできます。
https://github.com/alex-page/github-project-automation-plus

が、「ラベルを設定したら」というトリガーには少し工夫が必要です。
以下は Issue に PROJ A というラベルを設定したら Project A という GitHub Project の To do というカラムに追加するための Workflow の定義です。
これを .github/workflows のなかに *.yml で保存します。 (基本的なところは https://help.github.com/en/articles/configuring-a-workflow とかを参照)

name: 'Project A: Kanban Automation'

on: [issues]

jobs:
  automate-project-columns:
    runs-on: ubuntu-latest
    steps:
      - name: Move labeled issues into To do
        if: github.event.action == 'labeled' && github.event.label.name == 'PROJ A'
        uses: alex-page/github-project-automation-plus@master
        with:
          project: Project A
          column: To do
          repo-token: ${{ secrets.PERSONAL_TOKEN_FOR_KANBAN }}

repo-token については private repo の場合、Personal Access Token を作ってリポジトリに Secrets として登録しておく必要があるようです。
プリセットの secrets.GITHUB_TOKEN では必要なパーミッションが足りていないようです。

以下のようなパーミッションを指定します。

image.png

リポジトリにひもづく Project なら repo、Organization にひもづく Project なら admin:org のパーミッションが必要なはずです。 (多分)

試してないですが public repo であれば secrets.GITHUB_TOKEN でも問題ないと思います。

20
7
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
20
7