Skip to content

Commit 0463f7a

Browse files
authored
Merge branch 'doocs:main' into main
2 parents e836c99 + b2a6267 commit 0463f7a

File tree

542 files changed

+57811
-35141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

542 files changed

+57811
-35141
lines changed

.github/workflows/deploy.yml

Lines changed: 82 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: deploy
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- main
@@ -12,86 +13,118 @@ on:
1213
- lcof/**
1314
- lcci/**
1415
- basic/**
15-
workflow_dispatch:
16-
17-
env:
18-
MKDOCS_API_KEYS: ${{ secrets.MKDOCS_API_KEYS }}
19-
20-
permissions:
21-
contents: write
2216

2317
concurrency:
24-
group: ${{github.workflow}} - ${{github.ref}}
18+
group: ${{ github.workflow }} - ${{ github.ref }}
2519
cancel-in-progress: true
2620

2721
jobs:
28-
deploy:
22+
build:
2923
runs-on: ubuntu-latest
30-
if: github.repository == 'doocs/leetcode'
3124
steps:
32-
- uses: actions/checkout@v4
33-
- uses: actions/checkout@v4
25+
- name: Checkout main branch
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Checkout docs branch
31+
uses: actions/checkout@v4
3432
with:
3533
ref: docs
3634
path: mkdocs
37-
- run: |
38-
mv -f mkdocs/* .
35+
fetch-depth: 0
36+
37+
- name: Sync docs branch content
38+
run: |
39+
rsync -a --remove-source-files --exclude='.git' mkdocs/ ./
40+
rm -rf mkdocs
3941
mv solution/CONTEST_README.md docs/contest.md
4042
mv solution/CONTEST_README_EN.md docs-en/contest.md
43+
4144
- name: Configure Git Credentials
4245
run: |
43-
git config user.name github-actions[bot]
44-
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
46+
git config --global user.name github-actions[bot]
47+
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
4548
46-
- uses: actions/setup-python@v5
49+
- name: Setup Python
50+
uses: actions/setup-python@v5
4751
with:
4852
python-version: 3.x
4953

50-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
54+
- name: Restore pip cache
55+
uses: actions/cache@v4
56+
with:
57+
path: ~/.cache/pip
58+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
59+
restore-keys: |
60+
${{ runner.os }}-pip-
5161
52-
- uses: actions/cache@v4
62+
- name: Restore mkdocs-material cache
63+
uses: actions/cache@v4
5364
with:
54-
key: mkdocs-material-${{ env.cache_id }}
5565
path: .cache
66+
key: mkdocs-material-${{ env.cache_id }}
5667
restore-keys: |
5768
mkdocs-material-
58-
69+
5970
- name: Install dependencies
6071
run: |
6172
python3 -m pip install --upgrade pip
6273
python3 -m pip install -r requirements.txt
6374
python3 -m pip install "mkdocs-material[imaging]"
64-
sudo apt-get install pngquant
75+
sudo apt-get install -y pngquant
76+
77+
- name: Set MKDOCS_API_KEYS
78+
run: echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV
6579

66-
- run: |
80+
- name: Build site
81+
run: |
6782
python3 main.py
6883
mkdocs build -f mkdocs.yml
6984
mkdocs build -f mkdocs-en.yml
7085
71-
- name: Deploy
72-
uses: peaceiris/actions-gh-pages@v4
86+
- name: Generate CNAME
87+
run: echo "leetcode.doocs.org" > ./site/CNAME
88+
89+
- name: Commit committer cache to docs branch
90+
if: github.ref == 'refs/heads/main'
91+
env:
92+
GH_REPO: ${{ github.repository }}
93+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
run: |
95+
CACHE_FILE=".git-committers-cache.json"
96+
if [[ ! -f "$CACHE_FILE" ]]; then
97+
echo "Cache file not found; skip commit."
98+
exit 0
99+
fi
100+
101+
echo "Cloning docs branch ..."
102+
git clone --depth 1 --branch docs "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git" docs-cache
103+
cp "$CACHE_FILE" docs-cache/
104+
105+
cd docs-cache
106+
git config user.name github-actions[bot]
107+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
108+
109+
git add .git-committers-cache.json
110+
git commit -m "chore: update committer cache [skip ci]" || echo "No changes to commit"
111+
git push origin docs
112+
113+
- name: Upload artifact
114+
uses: actions/upload-pages-artifact@v3
73115
with:
74-
github_token: ${{ secrets.GITHUB_TOKEN }}
75-
publish_dir: ./site
76-
cname: leetcode.doocs.org
77-
78-
# sync:
79-
# runs-on: ubuntu-latest
80-
# needs: deploy
81-
# if: github.repository == 'doocs/leetcode'
82-
# steps:
83-
# - name: Sync to gitee.com
84-
# uses: wearerequired/git-mirror-action@master
85-
# env:
86-
# SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }}
87-
# with:
88-
# source-repo: [email protected]:doocs/leetcode.git
89-
# destination-repo: [email protected]:Doocs/leetcode.git
90-
91-
# - name: Build Gitee Pages
92-
# uses: yanglbme/gitee-pages-action@main
93-
# with:
94-
# gitee-username: yanglbme
95-
# gitee-password: ${{ secrets.GITEE_PASSWORD }}
96-
# gitee-repo: doocs/leetcode
97-
# branch: gh-pages
116+
path: ./site
117+
118+
deploy:
119+
needs: build
120+
runs-on: ubuntu-latest
121+
permissions:
122+
pages: write
123+
id-token: write
124+
environment:
125+
name: github_pages
126+
url: ${{ steps.deployment.outputs.page_url }}
127+
steps:
128+
- name: Deploy to GitHub Pages
129+
id: deployment
130+
uses: actions/deploy-pages@v4

.github/workflows/pr-add-label.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: pr-add-label
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
jobs:
8+
add-label:
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
runs-on: ubuntu-latest
13+
if: github.repository == 'doocs/leetcode'
14+
steps:
15+
- name: Check PR number
16+
id: pr_number
17+
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
18+
19+
- name: Run add-label Action
20+
uses: actionv/pr-label-action@master
21+
with:
22+
github_token: ${{ secrets.DOOCS_BOT_ACTION_TOKEN }}
23+
pr_number: ${{ env.PR_NUMBER }}
24+
organize_name: "doocs"
25+
team_name: "leetcode-algorithm"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
.vscode
44
.temp
55
.vitepress
6-
.cache
76
*.iml
87
__pycache__
98
/node_modules
109
/solution/result.json
1110
/solution/__pycache__
1211
/solution/.env
12+
.cache
13+
!.cache/plugin/
14+
!.cache/plugin/git-committers/
15+
!.cache/plugin/git-committers/page-authors.json

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<a href="https://opencollective.com/doocs-leetcode/backers/badge.svg" alt="backers on Open Collective"><img src="https://img.shields.io/opencollective/backers/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
1010
<a href="https://github.com/doocs/leetcode/stargazers"><img src="https://img.shields.io/github/stars/doocs/leetcode?color=4051B5&logo=github&style=flat-square" alt="stars"></a>
1111
<a href="https://github.com/doocs/leetcode/network/members"><img src="https://img.shields.io/github/forks/doocs/leetcode?color=4051B5&logo=github&style=flat-square" alt="forks"></a>
12-
<a href="https://opencollective.com/doocs-leetcode/sponsors/badge.svg" alt="Sponsors on Open Collective"><img src="https://img.shields.io/opencollective/sponsors/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
12+
<a href="https://opencollective.com/doocs-leetcode/sponsors/badge.svg" alt="Sponsors on Open Collective"><img src="https://img.shields.io/opencollective/sponsors/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a><br>
13+
<a href="https://deepwiki.com/doocs/leetcode"><img src="https://img.shields.io/badge/chat%20with-DeepWiki-4051B5?style=flat-square" alt="deepwiki"></a>
1314
</p>
1415

1516
## 介绍

README_EN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<a href="https://opencollective.com/doocs-leetcode/backers/badge.svg" alt="backers on Open Collective"><img src="https://img.shields.io/opencollective/backers/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
1010
<a href="https://github.com/doocs/leetcode/stargazers"><img src="https://img.shields.io/github/stars/doocs/leetcode?color=4051B5&logo=github&style=flat-square" alt="stars"></a>
1111
<a href="https://github.com/doocs/leetcode/network/members"><img src="https://img.shields.io/github/forks/doocs/leetcode?color=4051B5&logo=github&style=flat-square" alt="forks"></a>
12-
<a href="https://opencollective.com/doocs-leetcode/sponsors/badge.svg" alt="Sponsors on Open Collective"><img src="https://img.shields.io/opencollective/sponsors/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
12+
<a href="https://opencollective.com/doocs-leetcode/sponsors/badge.svg" alt="Sponsors on Open Collective"><img src="https://img.shields.io/opencollective/sponsors/doocs-leetcode?color=4051B5&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a><br>
13+
<a href="https://deepwiki.com/doocs/leetcode"><img src="https://img.shields.io/badge/chat%20with-DeepWiki-4051B5?style=flat-square" alt="deepwiki"></a>
1314
</p>
1415

1516
## Introduction

0 commit comments

Comments
 (0)