Skip to content

📊 Auto Update LeetCode Stats #249

📊 Auto Update LeetCode Stats

📊 Auto Update LeetCode Stats #249

Workflow file for this run

name: 📊 Auto Update LeetCode Stats
on:
push:
branches: [ main ]
paths:
- 'Daily-contest/**'
- 'scripts/**'
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
workflow_dispatch:
permissions:
contents: write
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- name: 🔄 Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: � Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: 📊 Run Progress Tracker
run: |
# Run the Node.js progress tracker script
node scripts/progress-tracker.js --save
- name: � Calculate Additional Metrics
id: metrics
run: |
# Read stats from the generated JSON file
TOTAL_PROBLEMS=$(node -p "JSON.parse(require('fs').readFileSync('stats.json', 'utf8')).totalProblems")
CURRENT_DAY=$(node -p "JSON.parse(require('fs').readFileSync('stats.json', 'utf8')).currentDay")
SUCCESS_RATE=$(node -p "JSON.parse(require('fs').readFileSync('stats.json', 'utf8')).successRate")
DAYS_REMAINING=$(node -p "JSON.parse(require('fs').readFileSync('stats.json', 'utf8')).daysRemaining")
PROGRESS_PERCENTAGE=$(node -p "JSON.parse(require('fs').readFileSync('stats.json', 'utf8')).progressPercentage")
echo "totalProblems=$TOTAL_PROBLEMS" >> $GITHUB_OUTPUT
echo "currentDay=$CURRENT_DAY" >> $GITHUB_OUTPUT
echo "successRate=$SUCCESS_RATE" >> $GITHUB_OUTPUT
echo "daysRemaining=$DAYS_REMAINING" >> $GITHUB_OUTPUT
echo "progressPercentage=$PROGRESS_PERCENTAGE" >> $GITHUB_OUTPUT
- name: 📝 Commit Updated Stats
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Add the updated stats.json
git add stats.json
# Check if there are changes to commit
if ! git diff --staged --quiet; then
git commit -m "📊 Auto-update progress: Day ${{ steps.metrics.outputs.currentDay }}/90 | ${{ steps.metrics.outputs.totalProblems }} problems solved | ${{ steps.metrics.outputs.successRate }}% success rate"
git push
echo "✅ Stats updated successfully!"
else
echo "ℹ️ No changes to commit - stats are up to date"
fi
- name: � Display Summary
run: |
echo "🎯 === LEETCODE CHALLENGE SUMMARY ==="
echo "📅 Challenge Day: ${{ steps.metrics.outputs.currentDay }}/90"
echo "✅ Problems Solved: ${{ steps.metrics.outputs.totalProblems }}"
echo "📈 Success Rate: ${{ steps.metrics.outputs.successRate }}%"
echo "⏰ Days Remaining: ${{ steps.metrics.outputs.daysRemaining }}"
echo "🎯 Overall Progress: ${{ steps.metrics.outputs.progressPercentage }}%"
echo "=================================="