From 7ffb432f20959fc154955c6c6316f840cc4df4d3 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Fri, 9 Aug 2024 17:06:08 +1000 Subject: [PATCH] Fix: Check and handle multiline values Ensure a multiline strings are output in the correct format to GITHUB_ENV. Signed-off-by: Anil Belur --- .github/workflows/compose-packer-verify.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compose-packer-verify.yaml b/.github/workflows/compose-packer-verify.yaml index ff9c8b1..e4c9400 100644 --- a/.github/workflows/compose-packer-verify.yaml +++ b/.github/workflows/compose-packer-verify.yaml @@ -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 @@ -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<> "$GITHUB_ENV" + if (( $(grep -c . <<<"$encoded_val") > 1 )); then + printf '%s<> "$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'