-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 2.25 KB
/
Copy pathsync.yml
File metadata and controls
59 lines (50 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Sync LeetCode
# Mirrors recent LeetCode accepted submissions into this repo. See README
# for the one-time setup (secrets, verified email).
on:
schedule:
- cron: "0 0 * * *" # every 24 hours (UTC)
workflow_dispatch: # manual trigger from the Actions tab
permissions:
contents: write # the job commits and pushes solution folders
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history so backdated commits land correctly
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Configure git identity
run: |
git config user.name "leetcode-sync-bot"
# Replace with an email verified on your GitHub account, otherwise
# the backdated commits will not count toward your contribution graph.
git config user.email ugcire132@gmail.com
- name: Run sync
env:
LEETCODE_SESSION: ${{ secrets.LEETCODE_SESSION }}
LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN }}
LEETCODE_USERNAME: ${{ secrets.LEETCODE_USERNAME }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: python -m src.main
- name: Push commits
# src.main pushes on a clean run; running this unconditionally also
# flushes any commits made before a later step failed, so backdated
# commits are never stranded on the runner.
if: always()
run: git push
- name: Report sync failure
# The sync step exits non-zero when any submission fails (most often an
# expired LEETCODE_SESSION, which GitHub surfaces as a failed run and
# emails about). Emit a visible annotation in the run summary too.
if: failure()
run: |
echo "::error title=LeetCode sync failed::The sync run failed. The most likely cause is an expired LEETCODE_SESSION secret — refresh it from your browser (and LEETCODE_CSRF_TOKEN) in repo Settings → Secrets and variables → Actions. Check the 'Run sync' step logs above for details."
exit 1