ansible-collection-prometheus/.github/scripts/discover_role_repos.sh
gardar 8f9e86a905
fix: remove the need for setting _repo_type variable
Signed-off-by: gardar <gardar@users.noreply.github.com>
2024-09-30 15:42:03 +00:00

19 lines
528 B
Bash
Executable file

#!/usr/bin/env bash
#
# Description: Discover the upstream repo from each role default vars.
result=$(
for role_dir in roles/*/ ; do
role="$(basename "${role_dir}")"
role_repo=$(yq eval "._${role}_repo" "${role_dir}/vars/main.yml" 2>/dev/null)
yq eval "[{
\"repo\": \"${role_repo}\",
\"role\": \"${role}\",
\"type\": (.${role}_binary_url | split(\"/\")[2] | split(\".\")[0] // \"github\")
}]" "${role_dir}/defaults/main.yml" 2>/dev/null
done | yq -o json -I=0
)
echo "result=${result}"