GitHub Action
YAML to ENV
v3.0.1
Latest version
GitHub Action that reads values from a YAML file, setting them into the $GITHUB_ENV
of a job.
You can see an example workflow here: example.yaml
Key to env name happens using the following script:
tr '[:lower:]' '[:upper:]' | sed -E 's/[^a-zA-Z0-9_]/_/g';
You can see the exact logic here
Source YAML:
key: value
Output env:
KEY=value
Source YAML:
object:
key1: value1
key2: value 2
key3:
- nested value 1
- nested value 2
Output env:
OBJECT_KEY1=value1
OBJECT_KEY2=value 2
OBJECT_KEY3_0=nested value 1
OBJECT_KEY3_1=nested value 2
Source YAML:
multiline: |
value with
more than 1 line
Output env:
MULTILINE<<EOF
value with
more than 1 line
EOF
yaml-file:
required: true
description: "Filepath to YAML to parse"
yq-version:
required: false
default: "4.27.5"
description: "Version of yq to install, if not already in path. Tested with >= 4.25."
mask-values:
required: false
default: "false"
description: "Add value masking to all exported environment variable values (https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#example-masking-an-environment-variable)"
yq-installed:
description: "'true' if yq was installed by this action"
var-count:
description: "Number of environment variables defined from source YAML file."
yaml-keys:
description: "Comma-separated string of keys extracted from source YAML file."
env-names:
description: "Comma-separated string of exported environment variable names"