Closed3

actions/labeler v4 -> v5 のマイグレーション

snakasnaka

https://github.com/actions/labeler

v5 になって設定ファイルの構造が変更になったっぽい

Breaking changes in V5

The ability to apply labels based on the names of base and/or head branches was added (https://github.com/actions/labeler/issues/186 and https://github.com/actions/labeler/issues/54). The match object for changed files was expanded with new combinations in order to make it more intuitive and flexible (https://github.com/actions/labeler/issues/423 and https://github.com/actions/labeler/issues/101). As a result, the configuration file structure was significantly redesigned and is not compatible with the structure of the previous version. Please read the documentation below to find out how to adapt your configuration files for use with the new action version.

The bug related to the sync-labels input was fixed (https://github.com/actions/labeler/issues/112). Now the input value is read correctly.

By default, dot input is set to true. Now, paths starting with a dot (e.g. .github) are matched by default.

Version 5 of this action updated the runtime to Node.js 20. All scripts are now run with Node.js 20 instead of Node.js 16 and are affected by any breaking changes between Node.js 16 and 20.

snakasnaka

これまで、以下のように記述していたものを

hoge:
  - packages/foo/**
  - bar

以下のように変更した

hoge:
  - changed-files:
    - any-glob-to-any-file:
      - packages/foo/**
      - bar
snakasnaka

変更についての補足

Match Object

これまでラベル ( 上記での hoge ) の対する値は直接 glob パターンを書いていたが、v5 から Match Object に変更された。

Match Object では、ファイルの変更 ( changed-files ) やブランチ ( base-branch, head-branch ) を条件として設定できる。

自分の場合は、ファイルの変更だけが検知できたら良いので changed-files を利用した。

changed-files

この部分がやや分かりづらい気がしているが、

これまで適用していた条件は

『glob パターンが複数あったとき「いずれか」の glob パターンに対して、変更されたファイルのうち「いずれか」がマッチしているときにラベルを付与したい。』

だったので any-glob-to-any-file を選択した。

たとえば、上記の設定だと
packages/foo/ 配下のいずれかのファイルが変更されている」あるいは「 bar ファイルが変更されている」のいずれか、が検知されたときにラベルが付与されることを期待している。

このスクラップは5ヶ月前にクローズされました