Get only array element from a variable of github action

Viewed 33

In github action file, I am running an AWS CLI command and storing the output of using set-ouput and reusing it in next step.

name: abc-name
id: abc
bash : |
   set-ouput name=opValue::$(aws ......command.....)

name: check
bash : echo ${{steps.abc.output.opValue}}

but the aws command's output is in the form of array like ["value"] and same is getting stored in variable opValue.

In my next "check step", I want to only fetch value of it, not the array.

1 Answers

Use jq to select the first value of the aws command output and store only that as output:

set-ouput name=opValue::$(aws ......command..... | jq '.[0]')
Related