Skip to content

Commit

Permalink
Update GetDownloadCount.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
shupershuff authored Sep 12, 2024
1 parent e00a0e9 commit 75a7b58
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/GetDownloadCount.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@ jobs:
run: |
releases=$(curl -s https://api.github.com/repos/shupershuff/diablo2rloader/releases)
# Debug: Print releases to check the response
echo "Releases data: $releases"
# Check if releases is empty or not valid JSON
if [ -z "$releases" ] || ! echo "$releases" | jq empty; then
echo "Error: No releases found or invalid JSON response."
exit 1
fi
# Initialize variables for max downloads
max_download_count=0
release_with_max_downloads=""
# Loop through all releases and find the one with the highest download count
for release in $(echo "$releases" | jq -c '.[]'); do
release_data=$(echo "$release" | jq '.')
download_count=$(echo "$release_data" | jq '[.assets[].download_count] | add')
download_count=$(echo "$release_data" | jq '[.assets[].download_count // 0] | add')
# Check if this release has more downloads than the current max
if [ "$download_count" -gt "$max_download_count" ]; then
Expand All @@ -39,6 +48,7 @@ jobs:
echo "Max downloads: $max_download_count for release: $release_with_max_downloads"
echo "download_count=$max_download_count" >> $GITHUB_OUTPUT
- name: Update JSON File
run: |
echo '{
Expand Down

0 comments on commit 75a7b58

Please sign in to comment.