Skip to content

Commit

Permalink
Fix number of contributors if less than 30
Browse files Browse the repository at this point in the history
30 is the number of contributors per page. If less than 30 contributors exist, the link header doesnt exist
  • Loading branch information
MSt-10 authored Jun 25, 2024
1 parent 8d9acef commit 466b684
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ runs:
NUM_STARS=$(curl -s $API_URL | jq '.stargazers_count // 0')
NUM_CONTRIBUTORS=$(curl -s -I "${API_URL}/contributors?per_page=1" | grep -i 'link:' | sed -E 's/.*page=([0-9]+)>; rel="last".*/\1/')
# Get number of contributors, handle the case where pagination info might not be present (less than 30 contributors)
CONTRIBUTORS_LINK_HEADER=$(curl -s -I "${API_URL}/contributors?per_page=1" | grep -i 'link:')
if [ -z "$CONTRIBUTORS_LINK_HEADER" ]; then
NUM_CONTRIBUTORS=$(curl -s "${API_URL}/contributors" | jq 'length')
else
NUM_CONTRIBUTORS=$(echo "$CONTRIBUTORS_LINK_HEADER" | sed -E 's/.*page=([0-9]+)>; rel="last".*/\1/' || echo "1")
fi
echo "| Attribute | Value |"
echo "| ----------------- | ----- |"
echo "| Repository URL | $REPO_URL |"
Expand Down

0 comments on commit 466b684

Please sign in to comment.