Skip to content

Commit 3d55279

Browse files
authored
Update ci.yml
1 parent 778664f commit 3d55279

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,73 @@ on:
33
push:
44
branches:
55
- main
6+
pull_request:
7+
branches:
8+
- main
9+
610
permissions:
711
contents: write
12+
813
jobs:
14+
test:
15+
name: Test MkDocs Build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: 3.x
25+
26+
- name: Cache dependencies
27+
uses: actions/cache@v3
28+
with:
29+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
30+
path: ~/.cache/pip
31+
restore-keys: |
32+
${{ runner.os }}-pip-
33+
34+
- name: Install dependencies
35+
run: |
36+
pip install jieba mkdocs-material mkdocs-static-i18n
37+
38+
- name: Build the site for testing
39+
run: mkdocs build --strict
40+
941
deploy:
42+
name: Deploy to GitHub Pages
43+
needs: test
1044
runs-on: ubuntu-latest
45+
46+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
47+
1148
steps:
12-
- uses: actions/checkout@v4
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
1352
- name: Configure Git Credentials
1453
run: |
1554
git config user.name github-actions[bot]
1655
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
17-
- uses: actions/setup-python@v4
56+
57+
- name: Setup Python
58+
uses: actions/setup-python@v4
1859
with:
1960
python-version: 3.x
20-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
21-
- uses: actions/cache@v3
61+
62+
- name: Cache dependencies
63+
uses: actions/cache@v3
2264
with:
23-
key: mkdocs-material-${{ env.cache_id }}
24-
path: .cache
65+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
66+
path: ~/.cache/pip
2567
restore-keys: |
26-
mkdocs-material-
27-
- run: pip install jieba
28-
- run: pip install mkdocs-material
29-
- run: pip install mkdocs-static-i18n
30-
- run: mkdocs gh-deploy --force
68+
${{ runner.os }}-pip-
69+
70+
- name: Install dependencies
71+
run: |
72+
pip install jieba mkdocs-material mkdocs-static-i18n
73+
74+
- name: Deploy to gh-pages
75+
run: mkdocs gh-deploy --force

0 commit comments

Comments
 (0)