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 3 years have passed since last update.

GitHub ActionsでfromJsonを使おうとしたらset-outputでハマった話

Posted at

GitHub ActionsでPRが動いたらExpoをpublishしてそのQRコードをPRのコメントに貼るCIを作成した時にapp.jsonのslugの値を取得する際にハマったお話。

やろうとしていたこと

app.jsonの中身を別のstepでも参照できるようにして、その値をfromJsonでjsonのように扱ってslugの値を抜き出そうとしていた。


#.github/workflows/expo.yaml
      ...
      - name: Get app json
        id: app-json
        run: echo "::set-output name=appJson::$(cat ./app.json)"
      ...
        ${{ fromJson(steps.app-json.outputs.appJson).expo.slug }}
      ...

そのCIを動かしてみると、Error reading JObject from JsonReader.というエラーが発生した。

原因

この原因はset-outputに複数行の文字列をセットできないことだった。

対策

set-outputでjsonをセットする際に改行を削除するようにした。

echo "::set-output name=appJson::$(cat ./app.json | tr -d '\n')"

参考文献

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?