Skip to content

Commit 16c8ff9

Browse files
authored
Create main.yml
1 parent 333a418 commit 16c8ff9

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/main.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Convert and Publish Notebooks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
convert-and-publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/[email protected]
15+
16+
- name: Set up Python
17+
uses: actions/[email protected]
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install Poetry
22+
run: |
23+
curl -sSL https://install.python-poetry.org | python3 -
24+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV
25+
export PATH="$HOME/.local/bin:$PATH"
26+
27+
- name: Install Dependencies
28+
run: |
29+
poetry install
30+
31+
- name: Convert Notebooks to QMD
32+
run: |
33+
mkdir -p qmd
34+
for notebook in $(find . -name "*.ipynb"); do
35+
poetry run jupyter nbconvert --to markdown --output-dir=qmd "$notebook"
36+
done
37+
38+
- name: Create Index File
39+
run: |
40+
echo "# Index" > qmd/index.qmd
41+
for file in $(ls qmd/*.md); do
42+
title=$(basename "$file" .md)
43+
echo "- [$title](./$title.html)" >> qmd/index.qmd
44+
done
45+
46+
- name: Render QMD Files
47+
run: |
48+
mkdir -p rendered
49+
for qmd in $(find qmd -name "*.qmd"); do
50+
poetry run quarto render "$qmd" --to html --output-dir rendered
51+
done
52+
53+
- name: Move rendered files to docs
54+
run: |
55+
rm -rf ./docs
56+
mv ./rendered ./docs
57+
echo "" > ./docs/.nojekyll
58+
59+
- name: Push changes
60+
uses: ad-m/[email protected]
61+
with:
62+
github_token: ${{ secrets.GITHUB_TOKEN }}
63+
branch: main

0 commit comments

Comments
 (0)