Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christherama/render-json-template
GitHub Action for rendering a JSON template
https://github.com/christherama/render-json-template
Last synced: 9 days ago
JSON representation
GitHub Action for rendering a JSON template
- Host: GitHub
- URL: https://github.com/christherama/render-json-template
- Owner: christherama
- Created: 2022-10-02T11:50:43.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-05T04:21:38.000Z (about 2 years ago)
- Last Synced: 2024-03-14T20:04:49.544Z (8 months ago)
- Language: Python
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Render JSON Template GitHub Action
This action renders a given JSON template according to the field and values passed as inputs.
## Usage
```yaml
- uses: christherama/render-json-template@v1
with:
# Path to JSON file serving as the template for rendering an output file. Required.
json-file-path: path/to/file.json
# Multi-line string containing key/value pairs of JSON property paths and desired property values
field-value-pairs: |
$.some.path: "value"
$.some.items: [1, 2, 3]
```## Outputs
### `rendered-json-file`
Path to file containing JSON rendered from the base file provided, and injected with the key/value pairs provided.
## Example Usage
This example below displays the contents of the rendered file in the action output. It assumes that a file exists at the root of the repository containing this workflow named `test.json`, containing valid JSON.
```yaml
on:
push:
branches:
- mainjobs:
render-test-json:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- id: render
uses: christherama/render-json-template@v1
with:
json-file-path: test.json
field-value-pairs: |
$.some: "things"
$.items: [1.7, "hello"]
- run: |
cat ${{ steps.render.outputs.rendered-json-file }}
```## Reference
- This action is based on https://github.com/h2non/jsonpath-ng
- Supported JSON path syntax can be found at https://goessner.net/articles/JsonPath/