Skip to content
lock

GitHub Action

JSON to environment variables

v1.1.0 Latest version

JSON to environment variables

lock

JSON to environment variables

This action reads json file and writes its content as environment variables with optional secret masking

Installation

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

              

- name: JSON to environment variables

uses: rgarcia-phi/[email protected]

Learn more about this action in rgarcia-phi/json-to-variables

Choose a version

JSON to variables

This action reads json file and writes its content as environment variables with optional secret masking.

Inputs

filename

Required The JSON file.

prefix

The prefix. Default value json.

masked

Mask variables as secrets. Default value false.

Usage

File content

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

YML example

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