Skip to content

Commit db8afe6

Browse files
authored
Fix number of contributors if less than 30
30 is the number of contributors per page. If less than 30 contributors exist, the link header doesnt exist
1 parent 9e9354e commit db8afe6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ runs:
9494
NUM_STARS=$(curl -s $API_URL | jq '.stargazers_count // 0')
9595
NUM_CONTRIBUTORS=$(curl -s -I "${API_URL}/contributors?per_page=1" | grep -i 'link:' | sed -E 's/.*page=([0-9]+)>; rel="last".*/\1/')
9696
97+
# Get number of contributors, handle the case where pagination info might not be present (less than 30 contributors)
98+
CONTRIBUTORS_LINK_HEADER=$(curl -s -I "${API_URL}/contributors?per_page=1" | grep -i 'link:')
99+
if [ -z "$CONTRIBUTORS_LINK_HEADER" ]; then
100+
NUM_CONTRIBUTORS=$(curl -s "${API_URL}/contributors" | jq 'length')
101+
else
102+
NUM_CONTRIBUTORS=$(echo "$CONTRIBUTORS_LINK_HEADER" | sed -E 's/.*page=([0-9]+)>; rel="last".*/\1/' || echo "1")
103+
fi
104+
97105
echo "| Attribute | Value |"
98106
echo "| ----------------- | ----- |"
99107
echo "| Repository URL | $REPO_URL |"

0 commit comments

Comments
 (0)