Can somebody clarify how to access the object’s property inside the action? object.property or $object.property or ${object.property} or ${{object.property}} don’t work.
I created an object from the data from the JSON file using fromJson() method:
  - name: "Get env data"
    id: get_env_data
    run: |
      JSON=$(jq --arg inputEnv "${{ github.event.inputs.env_to_deploy }}" 'map(. | select(.deployEnv==$inputEnv) ) | .[0]' .github/workflows/test.json)
      JSON="${JSON//$'\n'/''}"
      JSON="${JSON//$'\r'/''}"
      JSON="${JSON//$'\s+'/''}"
      echo "JSON=$JSON"
      echo "::set-output name=deployment_env::$JSON"
    
  - name: "Set env data"
    run: |
      env_data=${{ fromJson(steps.get_env_data.outputs.deployment_env) }}
      echo "env_data=$env_data"
      echo $env_data.port
The JSON file is like that:
[
    {
        "env":"dev",
        "port":"8000",
        "db_host":"DEV_DB_HOST"
    },
    {
        "env":"dev2",
        "port":"8002",
        "db_host":"DEV2_DB_HOST"
    },
    {
        "env":"dev3",
        "port":"8003",
        "db_host":"DEV3_DB_HOST"
    }
]
Unfortunately, I couldn't manage to solve this issue properly. I chose this way to get properties from the JSON as @GuiFalourd suggested and many examples I saw:
PORT=${{fromJson(steps.get_env_data.outputs.deployment_env).port}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With