/get-json-paths-action

A GitHub Action to access deep values of JSON strings

Primary LanguageJavaScriptMIT LicenseMIT

💁‍♂️ This action is now obsolete

Use the built-in fromJSON(value) function instead

Get JSON paths action

A GitHub Action to access deep values of JSON strings

Build Status Greenkeeper

Usage

Minimal example

Name: Minimal example
on: [push]

jobs:
  minimal_example:
    runs-on: ubuntu-latest
    steps:
      - id: action_with_json_output
        run: 'echo ::set-output name=data::{ "foo": { "bar":"baz" } }'
      - id: data
        uses: gr2m/get-json-paths-action@v1.x
        with:
          json: ${{ steps.action_with_json_output.outputs.data }}
          bar: "foo.bar"
      - run: "echo bar is ${{ steps.data.outputs.bar }}"

Example with octokit/request-action

Name: Request example
on:
  push:
    branches:
      - master

jobs:
  request_example:
    runs-on: ubuntu-latest
    steps:
      - id: request
        uses: octokit/request-action@v2.x
        with:
          route: GET /repos/:owner/:repo/releases/latest
          owner: gr2m
          repo: get-json-paths-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - id: result
        uses: gr2m/get-json-paths-action@v1.x
        with:
          json: ${{ steps.request.outputs.data }}
          name: "name"
          tag_name: "tag_name"
          created_by: "author.login"
      - run: "echo latest release: ${{ steps.result.outputs.name }} (${{ steps.result.outputs.tag_name }}) by ${{ ${{ steps.result.outputs.login }}"

Debugging

To see additional debug logs, create a secret with the name: ACTIONS_STEP_DEBUG and value true.

How it works

get-json-paths-action is using lodash.get to access deep properties at the provided path. json is the only required input. All other inputs are turned into equally named outputs with the value at the given paths.

License

MIT