LoginSignup
1
1

More than 1 year has passed since last update.

GitHub Actionsの`outputs.<output_id>`に不正な記号が使われている場合の対処法

Last updated at Posted at 2022-09-07

要約

[]を使って以下のように書く。

${{ steps.hoge.outputs['hoge/fuga'] }}

※記事末尾の所感も見てね。

背景

GitHub Docsにはactionsの出力(outputs)について以下のように書かれている。

<output_id>は、outputsオブジェクト内でユニークな識別子でなければなりません。 <output_id>は、文字あるいは_で始める必要があり、英数字、-_しか使用できません。

しかしMarketplaceにあるactionsの中には、output_id/などの許可されていない記号を含む場合がある。

↓以下はrelease-please-actionの例。

release-please-actionではoutput_idにディレクトリ名を含む場合があり、以下のようなidが生成される場合がある。

"packages/one--release_created"

これを利用しようとして以下のように指定するとエラーになってしまう。

${{ steps.release.outputs.packages/one--release_created }}
Invalid workflow file: .github/workflows/ci.yml#L27
The workflow is not valid. .github/workflows/ci.yml (Line: 27, Col: 9): Unexpected symbol: 'packages/one--release_created'. Located at position 23 within expression: needs.release.outputs.packages/one--release_created

ワークアラウンド

[]を使って次のように記述すると正しく解釈される。

${{ steps.release.outputs['packages/one--release_created'] }}

所感

ドキュメントで「英数字、-_しか使用できません」と書いてある以上、いつ動かなくなるかも分からないので、該当のactionにissueを立てるなりして対応してもらうのが良いと思います。

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