Skip to content

Commit fe27129

Browse files
NaN
1 parent 063f7a5 commit fe27129

File tree

2 files changed

+59
-96
lines changed

2 files changed

+59
-96
lines changed

.github/workflows/compile-and-deploy.yml

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,66 @@ on:
44
workflow_dispatch:
55

66
jobs:
7-
compile-and-deploy:
7+
complie:
8+
name: 编译
89
runs-on: ubuntu-latest
10+
strategy:
11+
max-parallel: 1
12+
matrix:
13+
version: ['v1', 'v2']
914
steps:
10-
- name: 检出
11-
uses: actions/checkout@v4
12-
- name: 编译
15+
- uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.GH_TOKEN }}
18+
ref: ${{ matrix.version }}
19+
- name: Set up Python
20+
uses: actions/setup-python@v3
21+
with:
22+
python-version: '3.x'
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -r requirements/requirements.txt
27+
pip install mike==1.1.2
28+
python -m pip install --upgrade pip setuptools wheel
29+
- name: Config Git
30+
run: |
31+
git config user.name "$(git log -n 1 --pretty=format:%an)"
32+
git config user.email "$(git log -n 1 --pretty=format:%ae)"
33+
- name: Build
34+
run: |
35+
git fetch origin deploy:deploy
36+
mike deploy --push --branch deploy --rebase ${{ matrix.version }}
37+
if [[ ${{ matrix.version }} == "v1" ]]; then
38+
# 先默认v1,等v2上线后改成v2
39+
mike set-default -b deploy ${{ matrix.version }}
40+
fi
41+
42+
deploy:
43+
name: 部署
44+
runs-on: ubuntu-latest
45+
needs: complie
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
token: ${{ secrets.GH_TOKEN }}
50+
ref: deploy
51+
- name: tar
1352
run: |
14-
sudo apt-get update
15-
sudo apt-get install -y --no-install-recommends zip
16-
docker run --rm -v ${PWD}:/docs registry-hk.fit2cloud.com/public/mkdocs-material:latest build
17-
zip -r -q -9 site.zip site
18-
ls -la site.zip
19-
- name: 上传
53+
rm -rf docs.tar
54+
rm -rf docs.tar.gz
55+
tar -zcf docs.tar.gz --exclude=.git *
56+
ls -la
57+
- name: upload
2058
uses: appleboy/[email protected]
2159
with:
2260
host: ${{ secrets.MAXKB_DOCS_HOST }}
2361
username: ${{ secrets.MAXKB_DOCS_HOST_USERNAME }}
2462
port: 22
2563
key: ${{ secrets.MAXKB_DOCS_HOST_KEY }}
26-
source: "site.zip"
64+
source: "docs.tar.gz"
2765
target: /tmp
28-
- name: 部署
66+
- name: deploy
2967
uses: appleboy/[email protected]
3068
with:
3169
host: ${{ secrets.MAXKB_DOCS_HOST }}
@@ -34,9 +72,13 @@ jobs:
3472
port: 22
3573
script: |
3674
cd /tmp
37-
rm -rf site
38-
unzip site.zip
39-
rm -rf /opt/maxkb/docs/*
40-
mv /tmp/site/* /opt/maxkb/docs
75+
rm -rf docs
76+
mkdir -p docs
77+
cd docs
78+
mv /tmp/docs.tar.gz ./
79+
tar -zxf docs.tar.gz
80+
rm -f docs.tar.gz
81+
rm -rf /opt/maxkb/docs2/*
82+
mv /tmp/docs/* /opt/maxkb/docs2/
4183
/opt/nginx/bin/reload-nginx.sh
42-
rm -rf /tmp/site*
84+
rm -rf /tmp/docs*

.github/workflows/test.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)