Skip to content

Commit 528ad7e

Browse files
authored
Merge pull request #27 from cloudsmithy/main
Feat: 添加自动化 ebook 构建流程
2 parents b7974c0 + d32e28c commit 528ad7e

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/build-ebook.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build Markdown Ebook
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install dependencies
23+
run: |
24+
pip install nbconvert jupyter
25+
26+
- name: Create output directory
27+
run: mkdir -p _ebook
28+
29+
- name: Convert notebooks to Markdown
30+
run: |
31+
for chapter in ch1 ch2 ch3 ch4; do
32+
if [ -d "$chapter" ]; then
33+
mkdir -p "_ebook/$chapter"
34+
for notebook in "$chapter"/*.ipynb; do
35+
if [ -f "$notebook" ]; then
36+
jupyter nbconvert --to markdown --output-dir="_ebook/$chapter" "$notebook"
37+
fi
38+
done
39+
fi
40+
done
41+
42+
- name: Copy assets
43+
run: |
44+
# Copy image folders that may be referenced by markdown
45+
cp -r ch3/milvus_image_search_data _ebook/ch3/ 2>/dev/null || true
46+
cp -r ch3/docs _ebook/ch3/ 2>/dev/null || true
47+
cp -r ch4/images _ebook/ch4/ 2>/dev/null || true
48+
cp -r ch4/tutorial-yaml _ebook/ch4/ 2>/dev/null || true
49+
cp README.md README-zh.md _ebook/ 2>/dev/null || true
50+
51+
- name: Deploy to ebook branch
52+
uses: peaceiris/actions-gh-pages@v4
53+
with:
54+
github_token: ${{ secrets.GITHUB_TOKEN }}
55+
publish_dir: ./_ebook
56+
publish_branch: ebook

0 commit comments

Comments
 (0)