Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read specific key #21

Closed
navotera opened this issue Jul 15, 2022 · 4 comments
Closed

Read specific key #21

navotera opened this issue Jul 15, 2022 · 4 comments

Comments

@navotera
Copy link

I want to read specific key but it seems does not work with this code :

  • name: Echo package.json
    run: echo "${{ steps.package.outputs.content.version }}"

Maybe I miss something, any guidance is appreciated.

Thank you

@juliangruber
Copy link
Owner

juliangruber commented Jul 15, 2022

The content of outputs.content is a string and not yet a parsed object, so this should work:

run: echo "${{ JSON.parse(steps.package.outputs.content).version }}"

EDIT:

It's

run: echo "${{ fromJson(steps.package.outputs.content).version }}"

@juliangruber
Copy link
Owner

Please reopen if it doesn't work like this ✌️

@juliangruber juliangruber closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2022
@fiddlermikey
Copy link

Did this work for you? @juliangruber @navotera
I get the error :

Unrecognized named-value: 'JSON'. Located at position 1 within expression: JSON.parse ...

juliangruber added a commit that referenced this issue Aug 29, 2022
juliangruber added a commit that referenced this issue Aug 29, 2022
* ci: add test JSON #21

* fix ci
@juliangruber
Copy link
Owner

You're right, it should be this:

  run: echo "${{ fromJson(steps.package.outputs.content).version }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants