Simple and robust jq action offering updated jq versions, YAML input/output conversions, input from command or text & more!
The default behavior will take input from text or a command, run a filter, and make the output available to other steps.
- id: jq
uses: direct-actions/jq@v1
with:
filter: { user: .login }
input: ${{ github.event.pull_request.head.user }}
- run: |
echo "The user's login is ${{ fromJSON(steps.jq.outputs.output).user }}"
Additional jq flags can be specified by using jq argument long names as input names.
- uses: direct-actions/jq@v1
with:
filter: '"The user's login is \(.login)"'
input: ${{ github.event.pull_request.head.user }}
raw-output: true
While I prefer the long name syntax as it is self-documenting, you can also use the short argument syntax.
- uses: direct-actions/jq@v1
with:
arguments: -r
filter: '"The user's login is \(.login)"'
input: ${{ github.event.pull_request.head.user }}
- uses: direct-actions/jq@v1
with:
filter: |
.example_key |
length
input: |
example_key:
- a
- b
- c
yaml-input: true
yaml-output: true
Commands can be used for input.
- uses: direct-actions/jq@v1
with:
filter: |
map(
select(.included != 'false')
) |
length
input-command: /tmp/dump_json.sh
As can files.
- uses: direct-actions/jq@v1
with:
filter: |
map(
select(.included != 'false')
) |
length
input-files: /tmp/one.json /tmp/two.json