Skip to content

Commit ca51bf5

Browse files
committed
Fix "nothing to commit" issue
1 parent b5374d7 commit ca51bf5

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

.github/workflows/fetch_all_categories_workflow.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ jobs:
2424
GH_TOKEN_TRENDING: ${{ secrets.GH_TOKEN_TRENDING }}
2525
GH_TOKEN_NEW_RELEASES: ${{ secrets.GH_TOKEN_NEW_RELEASES }}
2626
GH_TOKEN_MOST_POPULAR: ${{ secrets.GH_TOKEN_MOST_POPULAR }}
27+
GH_TOKEN_TOPICS: ${{ secrets.GH_TOKEN_TOPICS }}
2728
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2829
run: |
2930
MIN_REMAINING=99999
3031
DEDICATED=0
3132
FALLBACK=0
32-
for label in TRENDING NEW_RELEASES MOST_POPULAR; do
33+
for label in TRENDING NEW_RELEASES MOST_POPULAR TOPICS; do
3334
VAR="GH_TOKEN_${label}"
3435
TOKEN="${!VAR}"
3536
if [ -z "$TOKEN" ]; then
@@ -81,6 +82,7 @@ jobs:
8182
- name: Initialize cached-data directories
8283
run: |
8384
mkdir -p cached-data/{trending,new-releases,most-popular}
85+
mkdir -p cached-data/topics/{privacy,media,productivity,networking,dev-tools}
8486
8587
- name: Set up Python
8688
uses: actions/setup-python@v5
@@ -97,12 +99,16 @@ jobs:
9799
GH_TOKEN_TRENDING: ${{ secrets.GH_TOKEN_TRENDING }}
98100
GH_TOKEN_NEW_RELEASES: ${{ secrets.GH_TOKEN_NEW_RELEASES }}
99101
GH_TOKEN_MOST_POPULAR: ${{ secrets.GH_TOKEN_MOST_POPULAR }}
102+
GH_TOKEN_TOPICS: ${{ secrets.GH_TOKEN_TOPICS }}
100103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101104
FORCE_REFRESH: ${{ inputs.force_refresh || 'false' }}
102105
run: |
103106
python scripts/fetch_all_categories.py
104107
105-
if git status --porcelain cached-data/ | grep -q .; then
108+
# Only check for actual JSON file changes (ignore empty directories)
109+
if find cached-data -name "*.json" -newer .git/HEAD -print -quit | grep -q .; then
110+
echo "changed=true" >> $GITHUB_OUTPUT
111+
elif git status --porcelain cached-data/ | grep '\.json' | grep -q .; then
106112
echo "changed=true" >> $GITHUB_OUTPUT
107113
else
108114
echo "changed=false" >> $GITHUB_OUTPUT
@@ -141,6 +147,18 @@ jobs:
141147
done
142148
done
143149
echo ""
150+
echo "### Topics"
151+
echo "| Topic | Platform | Repos |"
152+
echo "|-------|----------|-------|"
153+
for topic in privacy media productivity networking dev-tools; do
154+
for plat in android windows macos linux; do
155+
f="cached-data/topics/$topic/$plat.json"
156+
if [ -f "$f" ]; then
157+
echo "| $topic | $plat | $(jq .totalCount "$f") |"
158+
fi
159+
done
160+
done
161+
echo ""
144162
echo "API remaining: ${{ needs.check-rate-limit.outputs.remaining }}"
145163
} >> $GITHUB_STEP_SUMMARY
146164
@@ -149,12 +167,17 @@ jobs:
149167
run: |
150168
git config user.name "github-actions[bot]"
151169
git config user.email "github-actions[bot]@users.noreply.github.com"
152-
git add cached-data/**/*.json
153-
git commit -m "Update repository categories — $(date -u +'%Y-%m-%d %H:%M UTC')"
154-
for i in 1 2 3; do
155-
git push origin main && break
156-
sleep 5 && git pull --rebase origin main
157-
done
170+
# Only add JSON files that actually exist (avoids errors from empty topic dirs)
171+
find cached-data -name "*.json" -exec git add {} +
172+
if git diff --cached --quiet; then
173+
echo "No JSON files changed — skipping commit"
174+
else
175+
git commit -m "Update repository categories — $(date -u +'%Y-%m-%d %H:%M UTC')"
176+
for i in 1 2 3; do
177+
git push origin main && break
178+
sleep 5 && git pull --rebase origin main
179+
done
180+
fi
158181
159182
notify-on-failure:
160183
needs: [check-rate-limit, fetch-and-update]

0 commit comments

Comments
 (0)