Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
box

GitHub Action

JSON to variables

v1.0.1

JSON to variables

box

JSON to variables

This action reads json file and writes its content as environment variables

Installation

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

              

- name: JSON to variables

uses: antifree/[email protected]

Learn more about this action in antifree/json-to-variables

Choose a version

JSON to variables

This action reads json file and writes its content as environment variables.

Inputs

filename

Required The JSON file.

prefix

The prefix. Default value json.

Usage

File content

{
    "value": "value",
    "array": [
        {
            "value": "value 0"
        },
        "value 1"
    ],
    "obj": {
        "value1": "value1",
        "value2": "value2"
    }
}

YML example

- name: JSON to variables
  uses: antifree/[email protected]
  with:
    filename: 'test.json'
    prefix: test
- name: Show output
  run: echo "The time was ${{ env.test_value }}, ${{ env.test_array_0_value }}, ${{ env.test_obj_value1 }}"