Skip to content

Latest commit

 

History

History
54 lines (41 loc) · 1.48 KB

README.md

File metadata and controls

54 lines (41 loc) · 1.48 KB

Render JSON Template GitHub Action

This action renders a given JSON template according to the field and values passed as inputs.

Usage

- 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.

on:
  push:
    branches:
      - main

jobs:
  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