Star Counter API #782
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: Star Counter API | |
| on: | |
| watch: | |
| types: [started] | |
| schedule: | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| jobs: | |
| update-star-count: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Fetch star count | |
| id: stars | |
| run: | | |
| STARS=$(curl -s https://api.github.com/repos/jamone-de/korers | jq .stargazers_count) | |
| echo "count=$STARS" >> $GITHUB_OUTPUT | |
| - name: Update star count file | |
| run: | | |
| mkdir -p public | |
| echo '{"stars":${{ steps.stars.outputs.count }},"updated":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","goal":1000,"percentage":'$(echo "scale=2; ${{ steps.stars.outputs.count }} * 100 / 1000" | bc)'}' > public/stars.json | |
| - name: Commit and push | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add public/stars.json | |
| git diff --staged --quiet || git commit -m "Update star count" | |
| git push |