Skip to content

LeetCode Sync (Stable) #723

LeetCode Sync (Stable)

LeetCode Sync (Stable) #723

Workflow file for this run

name: LeetCode Sync (Stable)
on:
workflow_dispatch:
schedule:
# Runs every 30 minutes (best approximation of "update every time I submit")
- cron: "*/30 * * * *"
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 \
--verbose
- name: Organize by difficulty and generate analysis report
run: |
python scripts/LeetCode_Analyzer.py
- 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
run: |
git config user.name "leetcode-sync-bot"
git config user.email "actions@users.noreply.github.com"
if [ -n "$(git status --porcelain)" ]; then
git add -A
git commit -m "Sync LeetCode submissions + update analysis"
git push
else
echo "No changes to commit."
fi