Skip to content

Commit a30e03e

Browse files
committed
fix: properly handle inputs
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent a874dff commit a30e03e

1 file changed

Lines changed: 32 additions & 8 deletions

File tree

.github/actions/generate-catalogs/action.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ inputs:
66
required: false
77
type: string
88
image-types:
9-
description: "Image types to retrieve - space separated values"
9+
description: "Image types to retrieve - comma separated values"
1010
required: false
1111
type: string
1212
distributions:
13-
description: "OS distributions to retrieve - space separated values"
13+
description: "OS distributions to retrieve - comma separated values"
1414
required: false
1515
type: string
1616
regex:
@@ -38,10 +38,34 @@ runs:
3838
3939
- name: Generate catalogs
4040
shell: bash
41+
env:
42+
REGISTRY: ${{ inputs.registry }}
43+
IMAGE_TYPES: ${{ inputs.image-types }}
44+
DISTRIBUTIONS: ${{ inputs.distributions }}
45+
REGEX: ${{ inputs.regex }}
46+
OUTPUT_DIR: ${{ inputs.output-dir }}
4147
run: |
42-
python "$GITHUB_ACTION_PATH/catalogs_generator.py" \
43-
${{ inputs.registry && format('--registry "{0}"', inputs.registry) || '' }} \
44-
${{ inputs.image-types && format('--image-types {0}', inputs.image-types) || '' }} \
45-
${{ inputs.distributions && format('--distributions {0}', inputs.distributions) || '' }} \
46-
${{ inputs.regex && format('--regex \'{0}\'', inputs.regex) || '' }} \
47-
--output-dir ${{ inputs.output-dir }}
48+
set -euo pipefail
49+
ARGS=()
50+
51+
if [[ -n "${REGISTRY:-}" ]]; then
52+
ARGS+=( --registry "$REGISTRY" )
53+
fi
54+
55+
if [[ -n "${IMAGE_TYPES:-}" ]]; then
56+
IFS=',' read -r -a image_types <<< "$IMAGE_TYPES"
57+
ARGS+=( --image-types "${image_types[@]}" )
58+
fi
59+
60+
if [[ -n "${DISTRIBUTIONS:-}" ]]; then
61+
IFS=',' read -r -a distributions <<< "$DISTRIBUTIONS"
62+
ARGS+=( --distributions "${distributions[@]}" )
63+
fi
64+
65+
if [[ -n "${REGEX:-}" ]]; then
66+
ARGS+=( --regex "$REGEX" )
67+
fi
68+
69+
ARGS+=( --output-dir "$OUTPUT_DIR" )
70+
71+
python "$GITHUB_ACTION_PATH/catalogs_generator.py" "${ARGS[@]}"

0 commit comments

Comments
 (0)