Merge pull request #72 from wuyoscar/update/2026-03-31 #12
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 Leaderboard Chart | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'assets/leaderboard_history.json' | |
| jobs: | |
| generate-chart: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| - name: Generate chart | |
| run: uv run scripts/gen_leaderboard_chart.py | |
| - name: Create PR if changed | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add assets/leaderboard_progress.svg | |
| if git diff --staged --quiet; then | |
| echo "No changes to chart" | |
| else | |
| BRANCH="auto/chart-update-$(date +%Y%m%d-%H%M%S)" | |
| git checkout -b "$BRANCH" | |
| git commit -m "chore: auto-update leaderboard chart" | |
| git push -u origin "$BRANCH" | |
| PR_URL="https://github.com/${{ github.repository }}/pull/new/$BRANCH" | |
| if gh pr create --title "chore: auto-update leaderboard chart" \ | |
| --body "Auto-generated by GitHub Actions after leaderboard_history.json change." \ | |
| --base main --head "$BRANCH"; then | |
| echo "PR created successfully." | |
| else | |
| echo "GitHub Actions is not permitted to create PRs in this repository." | |
| echo "Open this URL to create the PR manually: $PR_URL" | |
| { | |
| echo "## Leaderboard Chart Update" | |
| echo | |
| echo "A branch with the updated chart was pushed successfully:" | |
| echo "- \`$BRANCH\`" | |
| echo | |
| echo "GitHub Actions could not create the PR automatically." | |
| echo "Create it manually here:" | |
| echo "- $PR_URL" | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |