Refresh package stats #160
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Refresh package stats | |
| # Hourly refresh of stars / forks / last-updated in packages/packages.json from the | |
| # GitHub (and GitLab) APIs, committed back to the branch so the site serves fresh numbers. | |
| on: | |
| schedule: | |
| - cron: '17 * * * *' # every hour at :17 (off the top of the hour — GitHub's scheduler is busiest then) | |
| workflow_dispatch: {} # allow manual runs from the Actions tab | |
| permissions: | |
| contents: write # lets the default GITHUB_TOKEN push the updated JSON | |
| concurrency: | |
| group: refresh-package-stats | |
| cancel-in-progress: false | |
| jobs: | |
| refresh: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Refresh stars / forks / updated | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 5000 req/hr, and read access to public repos | |
| run: node scripts/update-package-stats.mjs | |
| - name: Commit if changed | |
| run: | | |
| if [ -n "$(git status --porcelain packages/packages.json)" ]; then | |
| git config user.name 'github-actions[bot]' | |
| git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| git add packages/packages.json | |
| git commit -m 'Refresh package stars/forks/stats' | |
| git push | |
| echo "Pushed refreshed stats." | |
| else | |
| echo "No stat changes." | |
| fi |