mikefarah / yq

yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor

Home Page:https://mikefarah.gitbook.io/yq/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

value for env variable not provided in env() GitHub Workflow

ma185417 opened this issue · comments

I am trying to use yq to pull out keys & values from JSON and do some manipulation to it in order to create a YAML which represent XML.

{ "key1": "value", "key2": "value" }

I got those two commands:


export yq_data=$(yq -r 'to_entries[] | "data: \n +@name: \"" + .key + "\" \n value: \"" + .value + "\" "' keys.json)
yq -i '.a.c.c.json = env(yq_data)' some-yaml-file.yaml

both running fine on local machine (mac) but when I tried to run it inside Github Workflow it fails to read the env as
Error: value for env variable 'yq_data' not provided in env()

this is how I run it inside the job:

  • name: create XML
    run: |
    yq --version
    echo yq_data=$(yq -r 'to_entries[] | "data: \n +@name: "" + .key + "" \n value: "" + .value + "" "' keys.json)
    yq '.a.b.c.json = env(yq_data)' some-yaml-file.yaml

Version of yq: 4.44.1
Operating system: ubuntu

it was a wrong configuration done by me