LeetCode Synchronizer is a GitHub Action that automatically collects and organizes LeetCode submissions into a GitHub repository.
Here's a sample repository created using LeetCode Synchronizer: leetcode-synchronizer-sample
- Fully automated collection of all your latest accepted submissions with minimal effort setup
- Single commit for each submission stamped with the original submission date for building rich and accurate contributions graph
- Automated git pushes to the remote repository with every action triggers
- Auto-generate README.md based on retrieved submissions
-
Retrieve LeetCode cookies
- Login to LeetCode
- Open
Web Developer Tools
- Find
https://leetcode.com
fromStorage > Cookies
- Copy values for cookies
LEETCODE_SESSION
andcsrftoken
-
Create a GitHub repository for LeetCode synchronization
-
Create GitHub Secrets for LeetCode API access
- Open
Settings > Secrets and variables > Actions
from the repository - Click
New repository secret
- Create a new secret
LEETCODE_SESSION
usingLEETCODE_SESSION
cookie value - Create a new secret
LEETCODE_CSRF_TOKEN
usingcsrftoken
cookie value
- Open
-
Give workflows write permissions in the repository for git pushes
- Open
Settings > Actions > General
from the repository - Select
Read and write permissions
fromWorkflow permissions
and save
- Open
-
Create GithHub Action
-
Create a workflow directory
.github/workflows/
-
Create a workflow file, e.g.,
leetcode_synchronizer.yml
-
Copy the following YAML contents into the
leetcode_synchronizer.yml
file:name: LeetCode Synchronizer on: workflow_dispatch jobs: build: runs-on: ubuntu-latest steps: - name: Run LeetCode Synchronizer uses: dos-m0nk3y/[email protected] with: GITHUB_TOKEN: ${{ github.token }} LEETCODE_SESSION: ${{ secrets.LEETCODE_SESSION }} LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN }}
-
-
Trigger GitHub action
- Open
Actions > LeetCode Synchronizer
from the repository - Click
Run workflow > Run workflow
- Open
GITHUB_TOKEN
- required. GitHub token used in pushing submissions to the repositoryLEETCODE_SESSION
- required. LeetCode session used in accessing LeetCode APILEETCODE_CSRF_TOKEN
- required. LeetCode CSRF token used in accessing LeetCode API