Skip to content
play

GitHub Action

Render json

v2.0.2 Latest version

Render json

play

Render json

render json file with environment variables

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Render json

uses: loveloper44/[email protected]

Learn more about this action in loveloper44/render-json-action

Choose a version

render-json-action

This action render json file with environment variables and return rendered json file path

Example usage

- uses: loveloper44/[email protected]
  id: render
  with:
    json: jsonFilePath

- name: Get the output
  run: echo "${{ steps.render.outputs.result }}"

Json file

Create input json file

{
  "app": {
    "service_id": "%s ENV_SERVICE_ID"
  },
  "db":{
    "host": "%s ENV_DB_HOST",
    "port": "%d ENV_DB_PORT",
    "user_name": "%s ENV_DB_USER_NAME",
    "user_password": "%s ENV_DB_USER_PASSWORD",
  }
}

You can use 4 types like below

  • %d number
  • %s string
  • %b boolean
  • %f float

Action will render json file with environment variables and return rendered json file path

{
  "app": {
    "service_id": "TestService"
  },
  "db":{
    "host": "localhost",
    "port": 3306,
    "user_name": "user",
    "user_password": "password",
  }
}