Giter Club home page Giter Club logo

jq-action's Introduction

Run jq

Run jq on your data and get result as output

Inputs

cmd

Required This is the actual command that will be passed along

multiline

Optional. Default false.

Value Behavior
true Multiple lines of output will be captured. Useful for capturing lists.
false Only the first line of the output will be captured. The rest will be written to stdout.

Outputs

value

This is the actual result of the command executing

Example usage

uses: sergeysova/jq-action@v2
with:
  cmd: jq -n env

Using output

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    
      - name: Extract version from package.json
        uses: sergeysova/jq-action@v2
        id: version
        with:
          cmd: 'jq .version package.json -r'
      
      - name: Show my version
        run: 'echo "version ${{ steps.version.outputs.value }}"'

Using multiline output

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    
      - name: Extract all keywords from package.json
        uses: sergeysova/jq-action@v2
        id: keywords
        with:
          cmd: 'jq .keywords[] package.json -r'
          multiline: true
      
      - name: Show keywords
        run: |
          keywords="${{ steps.keywords.outputs.value }}"
          for keyword in $keywords; do
            echo "$keyword"
          done

jq-action's People

Contributors

delmendo avatar kennethkalmer avatar norman-zon avatar rosshamish avatar satoryu avatar sergeysova avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jq-action's Issues

Using variables into cmd

Hey,

Into cmd is it possible to use github input variables like :

- name: My cmd
  uses: sergeysova/jq-action@v2
  with:
    cmd: 'echo "version ${{ github.event.inputs.version }}"'

/entrypoint.sh: line 14: $GITHUB_OUTPUT: ambiguous redirect

Initial checklist

Affected packages and versions

v2

Link to runnable example

No response

Steps to reproduce

I am using your workflow in an organisation workflow, and although it was running with no problem for a few months, today it started erroring out.

Expected behavior

The expected behaviour would be to set the $GITHUB_OUTPUT correctly.

Actual behavior

What is happening is erroring out:
image

Runtime

Other (please specify in steps to reproduce)

Package manager

No response

OS

No response

Build and bundle tools

No response

Deprecated set-output

Initial checklist

Affected packages and versions

v2

Link to runnable example

No response

Steps to reproduce

Create an action as explained on README.md

      - name: Extract version from package.json
        uses: sergeysova/jq-action@v2
        id: version
        if: ${{ inputs.push == true }}
        with:
          cmd: 'jq .version apps/${{ inputs.app }}/package.json -r'

Expected behavior

No warnings

Actual behavior

Warning: The set-output command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Runtime

Node v16

Package manager

yarn v2

OS

Linux

Build and bundle tools

Next.js

Multiline output

Hey there, thanks for the action. Would you be open to accepting a PR that adds support for multiline output? It's helpful for example when outputting one field from each item in a list. Right now, if the jq output has multiple lines, only the first line is set as the output, and the rest of the lines are just written to stdout.

It would look like this:

    - name: Extract contributed themes from package.json
      uses: .sergeysova/jq-action@v2
      id: themes
      with:
        cmd: 'jq .contributes.themes[].path ${{ inputs.working-directory }}/package.json --raw-output'
        multiline: true

And then the multiline output can be used like

    - name: Verify each contributed theme exists
      shell: bash
      run: |
        themes_in_package_json="${{ steps.themes.outputs.value }}"
        for theme in $themes_in_package_json; do
            ....
        done

Let me know! Thanks.

Allow running .sh file

Initial checklist

Problem

Hi! Can feature of providing path to the .sh file instead of command itself be added?

Solution

  - name: Extract version from package.json
        uses: sergeysova/jq-action@v2
        with:
          cmdPath: 'scripts/cmd.sh'

Alternatives

can't think about

Add windows support for GitHub Action

Initial checklist

Problem

It's a pity that this Action doesn't support Windows environment.

Solution

I am very sorry that I have limited ability to solve this problem independently.

Alternatives

I hope developers can solve this problem as soon as possible. Thank you very much.

Tag v2 not pointing to latest v2.3.0

Initial checklist

Affected packages and versions

sergeysova/jq-action@v2

Link to runnable example

No response

Steps to reproduce

Create your .github workflow descriptor file and use this action:

uses: sergeysova/jq-action@v2
with:
  cmd: jq -n env

Expected behavior

After #9 being merged. The following error most NOT appear anymore at github action output logs:

The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Actual behavior

It stills appear as tag v2 point to commit acfe8e3 instead of commit a3f0d4f

Runtime

No response

Package manager

No response

OS

No response

Build and bundle tools

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.