Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcarbone/yaml-to-env-action
https://github.com/dcarbone/yaml-to-env-action
action actions environment-variables github-actions workflows yaml
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dcarbone/yaml-to-env-action
- Owner: dcarbone
- License: apache-2.0
- Created: 2022-09-28T13:22:00.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-06T03:20:13.000Z (10 days ago)
- Last Synced: 2024-11-06T03:36:20.370Z (10 days ago)
- Topics: action, actions, environment-variables, github-actions, workflows, yaml
- Language: Shell
- Homepage:
- Size: 25.4 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# YAML to ENV GitHub Action
[GitHub Action](https://docs.github.com/en/actions) that reads values from a YAML file, setting them into the `$GITHUB_ENV` of a job.
* [YAML to ENV GitHub Action](#yaml-to-env-github-action)
* [Example Workflow](#example-workflow)
* [Conversion Rules](#conversion-rules)
* [Names](#names)
* [Simple](#simple)
* [Nested Object](#nested-object)
* [Multiline value](#multiline-value)
* [Action Inputs](#action-inputs)
* [yaml-file](#yaml-file)
* [yq-version](#yq-version)
* [mask-values](#mask-values)
* [Action Outputs](#action-outputs)
* [yq-installed](#yq-installed)
* [var-count](#var-count)
* [yaml-keys](#yaml-keys)
* [env-names](#env-names)## Example Workflow
You can see an example workflow here: [example.yaml](./example.yaml)
## Conversion Rules
### Names
Key to env name happens using the following script:
```shell
tr '[:lower:]' '[:upper:]' | sed -E 's/[^a-zA-Z0-9_]/_/g';
```You can see the exact logic [here](./scripts/yaml-to-env.sh)
#### Simple
Source YAML:
```yaml
key: value
```Output env:
```text
KEY=value
```#### Nested Object
Source YAML:
```yaml
object:
key1: value1
key2: value 2
key3:
- nested value 1
- nested value 2
```Output env:
```text
OBJECT_KEY1=value1
OBJECT_KEY2=value 2
OBJECT_KEY3_0=nested value 1
OBJECT_KEY3_1=nested value 2
```#### Multiline value
Source YAML:
```yaml
multiline: |
value with
more than 1 line
```Output env:
```text
MULTILINE<= 4.25."
```#### mask-values
```yaml
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)"
```## Action Outputs
#### yq-installed
```yaml
yq-installed:
description: "'true' if yq was installed by this action"
```#### var-count
```yaml
var-count:
description: "Number of environment variables defined from source YAML file."
```#### yaml-keys
```yaml
yaml-keys:
description: "Comma-separated string of keys extracted from source YAML file."
```#### env-names
```yaml
env-names:
description: "Comma-separated string of exported environment variable names"
```