Skip to content

Commit

Permalink
Fix: Check and handle multiline values
Browse files Browse the repository at this point in the history
Ensure a multiline strings are output in the correct format
to GITHUB_ENV.

Signed-off-by: Anil Belur <[email protected]>
  • Loading branch information
askb committed Aug 9, 2024
1 parent 46eeca3 commit 7ffb432
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/compose-packer-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jobs:
with:
secrets: ${{ inputs.ENV_VARS }}
- name: Double base64 decode credentials as store as environment variables
# yamllint disable rule:line-length
run: |
for kval in $ENV_SECRETS; do
# extract the key name
Expand All @@ -112,10 +113,14 @@ jobs:
encoded_val="${kval#*=}"
# mask to encoded value
echo ::add-mask::"$encoded_val"
# yamllint disable-line rule:line-length
printf '%s<<EOF\n%s\nEOF\n' "$key" "$encoded_val" >> "$GITHUB_ENV"
if (( $(grep -c . <<<"$encoded_val") > 1 )); then
printf '%s<<EOF\n%s\nEOF\n' "$key" "$encoded_val" >> "$GITHUB_ENV"
else
printf '%s\n' "$key=$encoded_val" >> "$GITHUB_ENV"
fi
fi
done
# yamllint enable rule:line-length
- name: Create cloud-env file required for packer
id: create-cloud-env-file
if: steps.changes.outputs.src == 'true'
Expand Down

0 comments on commit 7ffb432

Please sign in to comment.