-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |