Skip to content

Commit 21b0588

Browse files
author
Create Index Workflow
committed
...
1 parent ae69b00 commit 21b0588

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jq . extra-cheat-sheets.json >/dev/null
1414
readme_update() {
1515

1616
# Check "last_updated" field to update stars/forks in extra-cheat-sheets.json
17-
max_updates=50
17+
max_updates=25
1818
jq -c '. | to_entries[]' extra-cheat-sheets.json | while read -r entry; do
1919
# Eventual consistency, do no update to much to not hit GitHub API quota
2020
if [ "$max_updates" -le 0 ]; then
@@ -28,13 +28,18 @@ readme_update() {
2828
if [ -z "$last_updated" ] || [ "$(date -d "$last_updated" +%s 2>/dev/null || echo 0)" -lt "$(date -d '30 days ago' +%s)" ]; then
2929
echo "Updating stats for $key"
3030
max_updates=$((max_updates - 1))
31+
sleep 1
3132

3233
repo=$(echo "$value" | jq -r '.github')
3334
if [ -n "$repo" ]; then
3435
repo_api_url="https://api.github.com/repos/$repo"
3536
repo_data=$(curl -s "$repo_api_url")
3637
stars=$(echo "$repo_data" | jq -r '.stargazers_count // 0')
3738
forks=$(echo "$repo_data" | jq -r '.forks_count // 0')
39+
if [ $stars -eq 0 ]; then
40+
echo "ERROR: Fail to fetch stars"
41+
continue
42+
fi
3843

3944
jq --arg key "$key" --arg stars "$stars" --arg forks "$forks" --arg date "$(date -I)" \
4045
'.[$key] |= . + {stars: ($stars | tonumber), forks: ($forks | tonumber), last_updated: $date}' extra-cheat-sheets.json >tmp.json && mv tmp.json extra-cheat-sheets.json

0 commit comments

Comments
 (0)