1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Githubのラベルを管理・運用する俺的ベストプラクティス

Last updated at Posted at 2023-04-04

GitHubを使って開発を進める時、ラベルを使うと思います。(使わない人はこの記事は対象外です)

そのラベル、ちゃんと管理できていますか?
手動でポチポチ設定・管理することもできますが、ええいめんどくせええええと思いませんか?

リポジトリごとの管理をコードベースで行ってみようと思います。
今回は、mainブランチへのPushをトリガーとして設定しますが、用件や開発フローに合わせてカスタマイズ可能です。

下記のパッケージを使います。昔から使われている良ツールです。

必要な設定

PersonalAccess Tokenの生成・格納

  1. https://github.com/settings/tokens でアクセストークンを作っておきます。
    • 権限のスコープははrepoがあれば十分です
  2. リポジトリのsettingsから、Actions Secretを設定
    • これをWorkflowから呼びます
    • スクリーンショット 2023-04-04 13.22.35.png

設定ファイル

  • labels.json(ラベルの定義)
  • Workflowファイル(GithubActionsのWorkflow定義)

labels.jsonファイル

GitHubのリソース関連のファイルなので、.github/labels.jsonに置いてます。

(例).github/labels.json
[
  {
    "name": "bug",
    "color": "FC2C2B",
    "aliases": [],
    "description": "不具合の修正",
    "delete": false
  },
  {
    "name": "feature",
    "color": "0E4BDB",
    "aliases": [],
    "description": "新機能",
    "delete": false
  },
  {
    "name": "document",
    "color": "F4BFD0",
    "aliases": [],
    "description": "ドキュメントの追加および修正",
    "delete": false
  },
  {
    "name": "refactor",
    "color": "AFD38D",
    "aliases": [],
    "description": "リファクタリング",
    "delete": false
  }
]

Workflowファイル

※最小構成です

.github/workflows/labels.yml
name: Update Labels
on:
  push:
    branches: [ main ]
jobs:
  label:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup Node.js
      uses: actions/setup-node@v2
    - name: Install dependencies
      run: yarn add -D @azu/github-label-setup
    - name: update label
      run: yarn github-label-setup --token ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_LABELS }} --labels .github/labels.json

結果

適当なIssue作成画面からラベルを振る時に設定通りになっていればOK🙆
スクリーンショット 2023-04-04 13.12.02.png

もちろん手動でもOK

もちろん、手動でラベルを登録することもできます。僕の前職の元CTOが記事を書いてます。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?