diff --git a/.github/workflows/GetDownloadCount.yml b/.github/workflows/GetDownloadCount.yml index 8e72f24..f020ece 100644 --- a/.github/workflows/GetDownloadCount.yml +++ b/.github/workflows/GetDownloadCount.yml @@ -21,17 +21,25 @@ jobs: # Fetch the releases releases=$(curl -s https://api.github.com/repos/shupershuff/diablo2rloader/releases) - # Directly validate the JSON format - echo "$releases" | jq empty || { echo "Error: Invalid JSON response."; exit 1; } + # Debug: Print raw JSON to check the response + echo "Raw releases data:" + echo "$releases" + + # Validate JSON format and check for errors + if ! echo "$releases" | jq empty > /dev/null 2>&1; then + echo "Error: Invalid JSON response." + exit 1 + fi # Initialize variables for max downloads max_download_count=0 release_with_max_downloads="" # Iterate through each release using a for loop - echo "$releases" | jq -c '.[]' | while IFS= read -r release; do - release_name=$(echo "$release" | jq -r '.tag_name') - download_count=$(echo "$release" | jq '[.assets[].download_count // 0] | add') + echo "$releases" | jq -c '.[]' | while read -r release; do + release_data=$(echo "$release" | jq '.') + release_name=$(echo "$release_data" | jq -r '.tag_name') + download_count=$(echo "$release_data" | jq '[.assets[].download_count // 0] | add') # Log the release name and download count for debugging echo "Release: $release_name, Download Count: $download_count"