ci(workflows): rename output variable matrix to image_list
The variable name `matrix` in the `detect-changes` job output was ambiguous and potentially confusing, as `matrix` is a reserved keyword in Gitea/GitHub Actions syntax for defining job strategies. This change renames the output variable to `image_list` to better reflect its content (a JSON array of image names) and avoid naming conflicts or confusion with the actual `strategy.matrix` configuration. Changes: - Renamed output `matrix` to `image_list` in `detect-changes` job. - Updated all shell script references in the change detection logic. - Updated the consumer job `build-push-images` to use `needs.detect-changes.outputs.image_list`.
This commit is contained in:
@@ -23,7 +23,7 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
image: alpine:3.20
|
image: alpine:3.20
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.changes.outputs.matrix }}
|
image_list: ${{ steps.changes.outputs.image_list }}
|
||||||
has_changes: ${{ steps.changes.outputs.has_changes }}
|
has_changes: ${{ steps.changes.outputs.has_changes }}
|
||||||
steps:
|
steps:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -49,20 +49,20 @@ jobs:
|
|||||||
if [ -d "images/$IMAGE" ] && [ -f "images/$IMAGE/Dockerfile" ]; then
|
if [ -d "images/$IMAGE" ] && [ -f "images/$IMAGE/Dockerfile" ]; then
|
||||||
echo "DEBUG: Image directory and Dockerfile exist."
|
echo "DEBUG: Image directory and Dockerfile exist."
|
||||||
# Use printf for safer output
|
# Use printf for safer output
|
||||||
printf "matrix=[\"%s\"]\n" "$IMAGE" >> $GITHUB_OUTPUT
|
printf "image_list=[\"%s\"]\n" "$IMAGE" >> $GITHUB_OUTPUT
|
||||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||||
echo "DEBUG: Set matrix=['$IMAGE']"
|
echo "DEBUG: Set image_list=['$IMAGE']"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Error: Image '$IMAGE' not found or missing Dockerfile at images/$IMAGE/Dockerfile"
|
echo "Error: Image '$IMAGE' not found or missing Dockerfile at images/$IMAGE/Dockerfile"
|
||||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||||
echo "matrix=[]" >> $GITHUB_OUTPUT
|
echo "image_list=[]" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "DEBUG: Input image name was empty after trimming."
|
echo "DEBUG: Input image name was empty after trimming."
|
||||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||||
echo "matrix=[]" >> $GITHUB_OUTPUT
|
echo "image_list=[]" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -84,18 +84,18 @@ jobs:
|
|||||||
if [ ! -s valid_images.txt ]; then
|
if [ ! -s valid_images.txt ]; then
|
||||||
echo "No valid images detected."
|
echo "No valid images detected."
|
||||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||||
echo "matrix=[]" >> $GITHUB_OUTPUT
|
echo "image_list=[]" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
# Convert list to JSON array using jq
|
# Convert list to JSON array using jq
|
||||||
JSON=$(cat valid_images.txt | jq -R -s -c 'split("\n") | map(select(length > 0))')
|
JSON=$(cat valid_images.txt | jq -R -s -c 'split("\n") | map(select(length > 0))')
|
||||||
echo "Detected images: $JSON"
|
echo "Detected images: $JSON"
|
||||||
echo "matrix=$JSON" >> $GITHUB_OUTPUT
|
echo "image_list=$JSON" >> $GITHUB_OUTPUT
|
||||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Show detected changes
|
- name: Show detected changes
|
||||||
run: |
|
run: |
|
||||||
echo "Matrix: ${{ steps.changes.outputs.matrix }}"
|
echo "Image List: ${{ steps.changes.outputs.image_list }}"
|
||||||
echo "Has changes: ${{ steps.changes.outputs.has_changes }}"
|
echo "Has changes: ${{ steps.changes.outputs.has_changes }}"
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -109,7 +109,7 @@ jobs:
|
|||||||
image: docker:cli
|
image: docker:cli
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
image: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
|
image: ${{ fromJson(needs.detect-changes.outputs.image_list) }}
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
steps:
|
steps:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
Reference in New Issue
Block a user