Skip to content

Commit

Permalink
Merge pull request #1 from dcarbone/dcarbone/updates
Browse files Browse the repository at this point in the history
updates:
  • Loading branch information
dcarbone authored Oct 12, 2022
2 parents 5ba9b68 + 24ff35b commit c3ce8be
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ jobs:
yep
'
'${{ env.STRING_MULTILINE_WITH_EQUALS }}'
'HYPHENATED_KEY'
"hi there."
'${{ env.HYPHENATED_KEY }}'
'SECOND_HYPHENATED_KEY'
'hi there.'
'${{ env.SECOND_HYPHENATED_KEY }}'
'KEY_WITH__WEIRD___'
'what have you got.'
'${{ env.KEY_WITH__WEIRD___ }}'
)
for (( i=0; i < "${#_EXPECTED_ENVS[@]}"; i+=3 )); do
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ jobs:
## 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](./action.yaml#L64)

#### Simple

Source YAML:
Expand Down
6 changes: 3 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ runs:
run: |
_yq_bin="$(which yq)"
if [ -f "${_yq_bin}" ]; then
echo "::set-output name=found::true"
echo "found=true" >> $GITHUB_OUTPUT
else
echo "::set-output name=found::false"
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: 'Install yq (${{ inputs.yq-version }})'
Expand All @@ -61,7 +61,7 @@ runs:
function _ltrim_one { printf '%s' "${1}" | sed 's/^[[:blank:]]//'; }
function _rtrim_one { printf '%s' "${1}" | sed 's/[[:blank:]]$//'; }
function _upper() { printf '%s' "${1}" | tr '[:lower:]' '[:upper:]'; }
function _env_name() { _upper "${1}" | tr '.' '_'; }
function _env_name() { _upper "${1}" | sed -E 's/[^a-zA-Z0-9_]/_/g'; }
_write_env_file_line() {
_debug_log "${1} >> $GITHUB_ENV"
Expand Down
4 changes: 2 additions & 2 deletions test-action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function _trim() { printf '%s' "${1}" | sed 's/^[[:blank:]]*//; s/[[:blank:]]*$/
function _ltrim_one { printf '%s' "${1}" | sed 's/^[[:blank:]]//'; }
function _rtrim_one { printf '%s' "${1}" | sed 's/[[:blank:]]$//'; }
function _upper() { printf '%s' "${1}" | tr '[:lower:]' '[:upper:]'; }
function _env_name() { _upper "${1}" | tr '.' '_'; }
function _env_name() { _upper "${1}" | sed -E 's/[^a-zA-Z0-9_]/_/g'; }

_write_env_file_line() {
_debug_log "${1} >> $GITHUB_ENV"
Expand Down Expand Up @@ -79,5 +79,5 @@ _parse_yq_output() {
}

_debug_log "Writing to \"$GITHUB_ENV\":"
_all_fields="$(yq -o p '.' "$(pwd)/test.inputs.yaml")"
_all_fields="$(yq -o p '.' "$(pwd)/test-values.yaml")"
_parse_yq_output "${_all_fields}"
6 changes: 6 additions & 0 deletions test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ string_multiline_with_equals: |
value
=
yep
hyphenated-key: hi there.

second-hyphenated-key: hi there.

'KEY$with weird*$!': what have you got.

0 comments on commit c3ce8be

Please sign in to comment.