-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
037b182
commit 41b65c5
Showing
4 changed files
with
118 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Convert Notebooks and Update Book | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'notebooks/**.ipynb' | ||
|
||
jobs: | ||
convert-and-copy: | ||
runs-on: ubuntu-latest | ||
|
||
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" --to qmd -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: Commit and Push Changes | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters