Skip to content

Commit

Permalink
Replace newline list builder step with github-script
Browse files Browse the repository at this point in the history
This resolves 1 code-scanning warning.

Change-type: patch
Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Dec 17, 2024
1 parent ffa7d5f commit 8bd08dc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 77 deletions.
93 changes: 38 additions & 55 deletions .github/workflows/flowzone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 8 additions & 22 deletions flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,30 +360,24 @@
GH_TOKEN: ${{ steps.gh_app_token.outputs.token || secrets.FLOWZONE_TOKEN }}

- &jsonArrayBuilder
name: Build JSON array
name: Build JSON list from comma-separated input
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
env:
INPUT: ${{ env.INPUT }}
DELIMITER: ${{ env.DELIMITER }}
with:
result-encoding: json
script: |
// Remove whitespace from input
const input = process.env.INPUT?.replace(/\s+/g, '') || '';
const delimiter = process.env.DELIMITER;
// Split by delimiter (will return [''] for empty input)
return input.split(delimiter);
return input.split(',');
- &newlineListBuilder
name: Build newline-separated list from JSON array
id: to_newline_list
run: |
build="$(echo "${{ join(fromJSON(env.INPUT),' ') }}" | tr " " "\n")"
DELIMITER="$(echo $RANDOM | md5sum | head -c 32)"
echo "build<<${DELIMITER}" >> "${GITHUB_OUTPUT}"
echo "${build}" >> "${GITHUB_OUTPUT}"
echo "${DELIMITER}" >> "${GITHUB_OUTPUT}"
name: Build newline-separated list from JSON list input
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
result-encoding: string
script: |
return process.env.INPUT.join('\n');
- &dockerPlatformSlugMap
PLATFORM_SLUG_MAP: >
Expand Down Expand Up @@ -2021,7 +2015,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.docker_images }}
DELIMITER: ","

- id: docker_images_crlf
<<: *newlineListBuilder
Expand All @@ -2032,7 +2025,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.bake_targets }}
DELIMITER: ","

- name: Check for docker compose test files
id: docker_compose_tests
Expand Down Expand Up @@ -2315,7 +2307,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.cargo_targets }}
DELIMITER: ","

- name: Check Cargo.toml
id: cargo_yml
Expand Down Expand Up @@ -2362,7 +2353,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.balena_slugs }}
DELIMITER: ","

- name: Check for balena.yml
id: balena_yml
Expand Down Expand Up @@ -2409,7 +2399,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.custom_test_matrix }}
DELIMITER: ","

# FIXME: remove this handling of deprecated comma-separated values
- &customValuesInput
Expand All @@ -2432,7 +2421,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.custom_publish_matrix }}
DELIMITER: ","

# FIXME: remove this handling of deprecated comma-separated values
- <<: *customValuesInput
Expand All @@ -2451,7 +2439,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ inputs.custom_finalize_matrix }}
DELIMITER: ","

# FIXME: remove this handling of deprecated comma-separated values
- <<: *customValuesInput
Expand Down Expand Up @@ -2973,7 +2960,6 @@ jobs:
<<: *jsonArrayBuilder
env:
INPUT: ${{ steps.setup_buildx.outputs.platforms }}
DELIMITER: ","

# only register qemu binfmt if the target platform is not supported by the host natively
- <<: *setupQemuBinfmt
Expand Down

0 comments on commit 8bd08dc

Please sign in to comment.