org-stars-badge #93
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: org-stars-badge | |
| on: | |
| workflow_dispatch: {} | |
| schedule: | |
| - cron: "0 */6 * * *" # every 6h | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup auth | |
| env: | |
| GH_TOKEN: ${{ secrets.ORG_TOKEN }} | |
| run: gh auth status || true | |
| - name: Compute total stars | |
| id: stars | |
| env: | |
| ORG: ModioStudio | |
| run: | | |
| # sum stargazers_count over all repos (public + private if token allows) | |
| TOTAL=$(gh api -H "X-GitHub-Api-Version: 2022-11-28" /orgs/$ORG/repos --paginate -q '.[].stargazers_count' | awk '{s+=$1} END{print s+0}') | |
| echo "total=$TOTAL" >> $GITHUB_OUTPUT | |
| - name: Write badge JSON | |
| run: | | |
| mkdir -p profile | |
| cat > profile/org-stars.json <<EOF | |
| {"schemaVersion":1,"label":"Stars","message":"${{ steps.stars.outputs.total }}","color":"yellow"} | |
| EOF | |
| - name: Commit badge JSON | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore: update org stars badge" | |
| file_pattern: "profile/org-stars.json" |