-
Notifications
You must be signed in to change notification settings - Fork 574
66 lines (55 loc) · 2.28 KB
/
convert-to-qmd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Convert Notebooks and Update Book
on:
push:
paths:
- 'notebooks/**.ipynb'
jobs:
convert-and-copy:
runs-on: ubuntu-latest
permissions:
contents: write # Ensure the job has write permissions
steps:
- name: Checkout the Linear_Algebra_with_Python repository
uses: actions/[email protected]
- name: Install Quarto
run: |
wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.56/quarto-1.5.56-linux-amd64.tar.gz
tar -xvzf quarto-1.5.56-linux-amd64.tar.gz
sudo cp -r quarto-1.5.56/* /usr/local/
- name: Convert Notebooks to QMD
run: |
mkdir -p converted_chapters
for notebook in notebooks/*.ipynb; do
quarto convert "$notebook" -o "converted_chapters/$(basename "$notebook" .ipynb).qmd"
done
- name: Checkout the weijie-chen.github.io repository
uses: actions/[email protected]
with:
repository: weijie-chen/weijie-chen.github.io
path: book_repo
- name: Copy Converted QMD Files to Book Repository
run: |
mkdir -p book_repo/linear-algebra-with-python-book/chapters
cp converted_chapters/*.qmd book_repo/linear-algebra-with-python-book/chapters/
- name: Update Table of Contents in index.html
run: |
toc=""
for chapter in book_repo/linear-algebra-with-python-book/chapters/*.qmd; do
chapter_name=$(basename "$chapter" .qmd)
toc="$toc<li>$chapter_name</li>\n"
done
sed -i '/<section class="table-of-contents">/,/<\/section>/{//!d}' book_repo/linear-algebra-with-python-book/index.html
sed -i "/<section class=\"table-of-contents\">/a $toc" book_repo/linear-algebra-with-python-book/index.html
- name: Set up SSH Agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Commit and Push Changes via SSH
run: |
cd book_repo
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add linear-algebra-with-python-book/chapters/*
git add linear-algebra-with-python-book/index.html
git commit -m "Updated chapters and Table of Contents"
git push [email protected]:weijie-chen/weijie-chen.github.io.git main