mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-24 14:45:39 +00:00
outputs support in the action
This commit is contained in:
parent
01e478e81d
commit
1a49f5222b
25
README.md
25
README.md
@ -209,3 +209,28 @@ yq e '.a.b | length' f1.yml f2.yml
|
||||
|
||||
## Known Issues / Missing Features
|
||||
- `yq` attempts to preserve comment positions and whitespace as much as possible, but it does not handle all scenarios (see https://github.com/go-yaml/yaml/tree/v3 for details)
|
||||
|
||||
## GitHub Action
|
||||
|
||||
If we want to use the yq action to look up a value from within a YAML file inside the repo, we can do this:
|
||||
|
||||
```yml
|
||||
- uses: actions/checkout@v2
|
||||
- name: Get SDK Version from config
|
||||
id: lookupSdkVersion
|
||||
uses: mikefarah/yq@master
|
||||
with:
|
||||
cmd: yq eval '.renutil.version' 'config.yml'
|
||||
- name: Restore Cache
|
||||
id: restore-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ../renpy
|
||||
key: ${{ runner.os }}-sdk-${{ steps.lookupSdkVersion.outputs.result }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-sdk
|
||||
# ... more
|
||||
```
|
||||
You can even lookup how the GitHub action [itself is configured](https://github.com/mikefarah/yq/issues/844#issuecomment-856700574)
|
||||
|
||||
If you [enable step debug logging](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging), you can see additional information about the exact command sent as well as the response returned within the GitHub Action logs.
|
||||
|
@ -1,11 +1,15 @@
|
||||
name: 'yq - portable yaml processor'
|
||||
description: 'create, read, update, delete, merge, validate and do more with yaml'
|
||||
icon: command
|
||||
color: gray-dark
|
||||
branding:
|
||||
icon: command
|
||||
color: gray-dark
|
||||
inputs:
|
||||
cmd:
|
||||
description: 'The Command which should be run'
|
||||
required: true
|
||||
outputs:
|
||||
result:
|
||||
description: "The complete result from the yq command being run"
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'github-action/Dockerfile'
|
||||
|
@ -1,4 +1,6 @@
|
||||
#!/bin/sh -l
|
||||
|
||||
echo "$1"
|
||||
eval $1
|
||||
echo "::debug::\$cmd: $1"
|
||||
RESULT=$(eval "$1")
|
||||
echo "::debug::\$RESULT: $RESULT"
|
||||
echo ::set-output name=result::"$RESULT"
|
||||
|
Loading…
Reference in New Issue
Block a user