Update Org Leaderboard #47
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: Update Org Leaderboard | |
| on: | |
| # Run daily at midnight UTC to keep leaderboard up to date | |
| schedule: | |
| - cron: '0 0 * * *' | |
| # Allow manual trigger from the Actions tab | |
| workflow_dispatch: | |
| # Grant write access so the workflow can commit and push README changes | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-readme: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| working-directory: profile/scripts | |
| - name: Generate leaderboard | |
| # GIT_PAT must be added as a repository secret (Settings > Secrets) | |
| run: node profile/scripts/updateReadme.js | |
| env: | |
| GIT_PAT: ${{ secrets.GIT_PAT }} | |
| - name: Commit & push changes | |
| env: | |
| GIT_PAT: ${{ secrets.GIT_PAT }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Use GIT_PAT to authenticate push (works for both public and private repos) | |
| git remote set-url origin https://x-access-token:${GIT_PAT}@github.com/${{ github.repository }}.git | |
| git add profile/README.md | |
| # Only commit if there are staged changes; exit gracefully otherwise | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: update leaderboard [skip ci]" | |
| git push origin HEAD:${{ github.event.repository.default_branch }} | |
| fi | |