You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
YAML to ENV
v2.0.0
GitHub Action that reads values from a YAML file, setting them into the $GITHUB_ENV
of a job.
name: YAML to Env Example Workflow
on:
workflow_dispatch:
inputs:
yaml-file:
type: string
required: false
description: "Path to YAML file to parse"
default: "test-values.yaml"
yq-version:
type: string
required: false
description: "Version of yq to install, if not already"
default: "4.27.5"
debug:
type: boolean
required: false
description: "Enable debug logging"
default: false
jobs:
yaml-to-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set ENV values from YAML
uses: dcarbone/[email protected]
with:
debug: '${{ inputs.debug }}'
yaml-file: '${{ inputs.yaml-file }}'
yq-version: '${{ inputs.yq-version }}'
- name: Print environment variables
run: |
printenv
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."
debug:
required: false
default: "false"
description: "Enable debug logging. This WILL print un-masked secrets to stdout, so use with caution."
yq-installed:
description: "'true' if yq was installed by this action"