From b680634b770c5a0c04f7ccf1f5eb1dfc381eacda Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Mon, 6 Oct 2025 07:25:38 -0400 Subject: [PATCH] yq tweaks. --- .gitea/workflows/compose-services-readme.yml | 31 +++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/compose-services-readme.yml b/.gitea/workflows/compose-services-readme.yml index b803686..4ba7388 100644 --- a/.gitea/workflows/compose-services-readme.yml +++ b/.gitea/workflows/compose-services-readme.yml @@ -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