yq tweaks.
This commit is contained in:
@@ -43,23 +43,40 @@ jobs:
|
||||
run: |
|
||||
echo "[]" > temp_services.json
|
||||
FOUND=0
|
||||
|
||||
COMPOSE_FILES=$(find . -type f -name "docker-compose*.yml" \
|
||||
-a ! -name "*windows*" \
|
||||
-a ! -name "*gui*" \
|
||||
-a ! -name "*macos*" \
|
||||
-a ! -name "*hivemind*" \
|
||||
-a ! -name "*server*" \
|
||||
| sort)
|
||||
|
||||
if [ -z "$COMPOSE_FILES" ]; then
|
||||
echo "No docker-compose files found. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Processing combined Compose files:"
|
||||
echo "$COMPOSE_FILES"
|
||||
|
||||
# Run yq once globally to resolve anchors, get all services
|
||||
yq -o=json eval-all 'explode(.) | .services | to_entries | map({"service": .key, "image": .value.image})' $COMPOSE_FILES > all_services.json
|
||||
|
||||
# Loop over files for logging and merging
|
||||
while IFS= read -r f; do
|
||||
[ -z "$f" ] && continue
|
||||
echo "Processing $f"
|
||||
# Extract JSON array for this compose file
|
||||
yq -o=json eval-all --yaml-fix-merge-anchor-to-spec=true 'explode(.) | .services | to_entries | map({"service": .key, "image": .value.image})' "$f" > tmp.json
|
||||
# Merge all arrays into one JSON array-of-arrays
|
||||
jq -s 'add' temp_services.json tmp.json > temp_merged.json
|
||||
mv temp_merged.json temp_services.json
|
||||
FOUND=1
|
||||
done <<< "${{ steps.find-compose-files.outputs.compose_files }}"
|
||||
done <<< "$COMPOSE_FILES"
|
||||
|
||||
if [ "$FOUND" -eq 0 ]; then
|
||||
echo "No docker-compose files found. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
jq 'unique_by(.service)' temp_services.json > services.json
|
||||
# Deduplicate services globally
|
||||
jq 'unique_by(.service)' all_services.json > services.json
|
||||
|
||||
- name: Generate Markdown Table
|
||||
uses: gazab/create-markdown-table@6686233d7008e8d8b9d4bbdbfd1fb1ae510019f0 # v1.0.7
|
||||
|
||||
Reference in New Issue
Block a user