Update Stats #104
  
    
      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 Stats | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # Runs every 2 hours | |
| - cron: "0 */2 * * *" | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-leetcode: | |
| name: Update local LeetCode stats card | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: npm install node-fetch@2 | |
| - name: Generate latest LeetCode SVG | |
| run: | | |
| mkdir -p assets | |
| node .github/scripts/update_leetcode.cjs | |
| - name: Commit and push updated LeetCode card | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add assets/leetcode.svg | |
| git commit -m "chore: update LeetCode stats" || echo "No changes to commit" | |
| git push |