GitHub Actions のワークフロー構文の公式ドキュメントを読んでいて、 on.workflow_dispatch.inputs のセクションにややこしい注意書きがあることに気がついた。
The information in the
inputscontext andgithub.event.inputscontext is identical except that theinputscontext preserves Boolean values as Booleans instead of converting them to strings. The choice type resolves to a string and is a single selectable option.
inputsコンテキストとgithub.event.inputsコンテキストの情報は同一ですが、inputsコンテキストではブール値が文字列に変換されずブール値のまま保持される点が異なります。選択型は文字列に変換され、単一の選択可能なオプションとなります。
GitHub Actions のワークフロー構文 - GitHub Enterprise Cloud Docs
なるほど on.workflow_dispatch.inputs から渡された値をワークフロー内部で受け取る方法として github.event.inputs と inputs があるらしい。
まとめるとこうだ。
github.event.inputs |
inputs |
|
|---|---|---|
| リリース | 2020年7月頃 | 2022年6月頃 |
| 使用シーン | workflow_dispatch でしか使えない |
workflow_dispatch と workflow_call で透過的に使える |
| 挙動 | type: boolean な値も文字列化される( 'true'/'false') |
type: boolean な値がそのまま渡される( true/false) |
github.event.inputs を参照すると真理値が文字列 'true'/'false' に変換されて渡される。(if: 節や JavaScript コード内では 'false' は Truthy だ!)
一方で inputs を参照していれば真理値がそのまま true/false で渡されるので、より素直に記述できる。
2026年現在は inputs の方を積極的に使ったほうがいいみたい。