Skip to content

Refresh themes-data.json #31

Refresh themes-data.json

Refresh themes-data.json #31

name: Refresh themes-data.json
on:
schedule:
# Daily at 06:30 UTC
- cron: "30 6 * * *"
workflow_dispatch:
jobs:
refresh:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- run: npm install
- name: Scrape themes from GitHub
run: node scripts/scrape.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git diff --quiet -- src/data/themes-data.json; then
echo "No changes."
else
git add src/data/themes-data.json
git commit -m "Refresh themes-data.json"
# Rebase onto any commits pushed while we were scraping, then retry once.
for attempt in 1 2 3; do
git pull --rebase origin main
if git push; then
exit 0
fi
echo "Push attempt $attempt failed; refetching and retrying..."
sleep 5
done
echo "Push failed after 3 attempts."
exit 1
fi