Skip to content

Commit

Permalink
add json key extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Aug 29, 2024
1 parent e816e7c commit 120b090
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tooling/github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Common GitHub Actions

Any of these actions can be referenced from your github actions pipeline

```yaml
uses: ctrlplane/tooling/github/json-key-extractor@main
```
21 changes: 21 additions & 0 deletions tooling/github/json-key-extractor/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "JSON Key Extractor"
description: "A composite action that parses a JSON string and extracts the value of a specified key."
inputs:
json-output:
description: "The JSON string from which to extract a value."
required: true
key:
description: "The key for which the value should be extracted from the JSON object."
required: true
outputs:
value:
description: "The extracted value associated with the specified key."
runs:
using: "composite"
steps:
- name: Extract value from JSON
id: extract
shell: bash
run: |
value=$(echo "${{ inputs.json-output }}" | jq -r ".${{ inputs.key }}")
echo "value=${value}" >> $GITHUB_OUTPUT

0 comments on commit 120b090

Please sign in to comment.