Skip to content

Commit 318c26a

Browse files
add workflows for github pages
1 parent 2bdb606 commit 318c26a

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- release/1.0
7+
- release/1.1
8+
- release/1.2
9+
- release/1.2.1
10+
permissions:
11+
contents: write
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Configure Git Credentials
18+
run: |
19+
git config user.name "github-actions[bot]"
20+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.9
24+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
25+
- uses: actions/cache@v4
26+
with:
27+
key: mkdocs-material-${{ env.cache_id }}
28+
path: .cache
29+
restore-keys: |
30+
mkdocs-material-
31+
- run: pip install -r docs/requirements.txt
32+
- run: mkdocs gh-deploy --force
33+
34+
- name: Deploy documentation
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
# 获取当前分支名称
39+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
40+
41+
# 根据分支名称部署相应的文档版本
42+
if [ "$BRANCH" == "deploy_in_gitpage" ]; then
43+
ALIAS_VERSION="latest"
44+
mike deploy --push --update-aliases $ALIAS_VERSION
45+
elif [ "$BRANCH" == "release/1.2" ]; then
46+
ALIAS_VERSION="release-1.2"
47+
mike deploy --push --update-aliases $ALIAS_VERSION
48+
elif [ "$BRANCH" == "release/1.1" ]; then
49+
ALIAS_VERSION="release-1.1"
50+
mike deploy --push --update-aliases $ALIAS_VERSION
51+
elif [ "$BRANCH" == "release/1.0" ]; then
52+
ALIAS_VERSION="release-1.0"
53+
mike deploy --push --update-aliases $ALIAS_VERSION
54+
fi
55+
56+
mike set-default --push latest

0 commit comments

Comments
 (0)