LeetCode Sync (Stable) #846
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: LeetCode Sync (Stable) | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| push: | |
| paths: | |
| - ".github/workflows/sync_LeetCode.yml" | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install leetcode-export | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install leetcode-export | |
| - name: Export accepted LeetCode submissions | |
| env: | |
| LEETCODE_COOKIES: ${{ secrets.LEETCODE_COOKIE }} | |
| run: | | |
| leetcode-export \ | |
| --cookies "$LEETCODE_COOKIES" \ | |
| --folder leetcode \ | |
| --problem-folder-name '${difficulty}_${question_id}-${title_slug}' \ | |
| --only-accepted \ | |
| --only-last-submission \ | |
| --no-problem-statement \ | |
| --verbose | |
| - name: Clean generated logs | |
| run: | | |
| rm -f debug.log | |
| find . -name "*.log" -delete | |
| - name: Organize by difficulty and generate analysis report | |
| run: | | |
| python scripts/LeetCode_Analyzer.py | |
| - name: Clean generated logs again | |
| run: | | |
| rm -f debug.log | |
| find . -name "*.log" -delete | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git status --porcelain | grep .; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push changes | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config user.name "leetcode-sync-bot" | |
| git config user.email "actions@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Sync LeetCode submissions + update analysis" | |
| git push |