-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
58 lines (52 loc) · 1.87 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: YAML to ENV
description: |
Parse all keys & values out of a YAML file, adding them to the $GITHUB_ENV file
branding:
icon: copy
color: blue
inputs:
yaml-file:
required: true
description: "Filepath to YAML to parse"
yq-version:
required: false
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)"
outputs:
yq-installed:
description: "'true' if yq was installed by this action"
value: "${{ steps.install-yq.outputs.installed == 'false' }}"
var-count:
description: "Number of environment variables defined from source YAML file."
value: "${{ steps.y2e.outputs.var-count }}"
yaml-keys:
description: "Comma-separated string of keys extracted from source YAML file."
value: "${{ steps.y2e.outputs.yaml-keys }}"
env-names:
description: "Comma-separated string of exported environment variable names"
value: "${{ steps.y2e.outputs.env-names }}"
runs:
using: composite
steps:
- name: Check yaml file existence
shell: bash
run: |
if ! [ -f '${{ inputs.yaml-file }}' ]; then
echo 'Configured YAML file "${{ inputs.yaml-file }}" not found'
exit 1
fi
- name: 'Install yq (${{ inputs.yq-version }})'
id: install-yq
uses: dcarbone/[email protected]
with:
version: '${{ inputs.yq-version }}'
- name: YAML to ENV
id: y2e
shell: bash
run: $GITHUB_ACTION_PATH/scripts/yaml-to-env.sh
env:
YAMLTOENV_MASK_VALUES: '${{ inputs.mask-values }}'
YAMLTOENV_YAML_FILE: '${{ inputs.yaml-file }}'