Skip to content

Commit 6388890

Browse files
deploy to gh-pages
1 parent 414c33b commit 6388890

File tree

4 files changed

+78
-71
lines changed

4 files changed

+78
-71
lines changed

.github/workflows/deploy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Deploy
16+
uses: peaceiris/actions-gh-pages@v4
17+
if: github.ref == 'refs/heads/main'
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
publish_dir: ./build

.github/workflows/publish-marimo.yml

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

contribution.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,37 @@ uv run marimo edit notebook.py --sandbox
4242

4343
### Publishing Notebooks
4444

45-
Add the following workflow to `.github/workflows/publish-marimo.yml`:
46-
47-
```yaml
48-
...
49-
jobs:
50-
publish:
51-
runs-on: ubuntu-latest
52-
steps:
53-
...
54-
- name: Export notebook
55-
run: |
56-
uv run marimo export html notebook.py -o build/notebook.html --sandbox
57-
...
58-
```
45+
To export your marimo notebooks to HTML locally:
46+
47+
1. Make sure the `export_notebook.sh` script is executable:
48+
49+
```bash
50+
chmod +x export_notebook.sh
51+
```
52+
53+
2. Run the script with your notebook name:
54+
55+
```bash
56+
# For notebooks in the root directory
57+
./export_notebook.sh notebook_name
58+
59+
# For notebooks in subdirectories
60+
./export_notebook.sh path/to/notebook_name
61+
```
62+
63+
For example:
64+
65+
```bash
66+
./export_notebook.sh data_science_tools/polars_vs_pandas
67+
./export_notebook.sh llm/pydantic_ai_examples
68+
```
69+
70+
The exported HTML files will be automatically deployed to GitHub Pages through the GitHub Actions workflow.
5971

6072
## Pull Request Process
6173

6274
1. Fork the repository
6375
2. Create a new branch for your feature
6476
3. Make your changes
65-
4. Submit a pull request with a clear description of changes
77+
4. Submit a pull request with a clear description of changes
78+

export_notebook.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Check if a notebook name was provided
4+
if [ -z "$1" ]; then
5+
echo "Error: Please provide a notebook name"
6+
echo "Usage: ./export_notebook.sh notebook_name"
7+
exit 1
8+
fi
9+
10+
# Get the notebook name without .py extension if provided
11+
notebook_name=${1%.py}
12+
13+
# Get the directory path
14+
dir_path=$(dirname "$notebook_name")
15+
notebook_base=$(basename "$notebook_name")
16+
17+
# Create build directory and subdirectories if they don't exist
18+
mkdir -p "build/$dir_path"
19+
20+
# Export the notebook to HTML
21+
echo "Exporting $notebook_name.py to HTML..."
22+
uv run marimo export html "$notebook_name.py" -o "build/$notebook_name.html" --sandbox
23+
24+
# Check if the export was successful
25+
if [ $? -eq 0 ]; then
26+
echo "Successfully exported $notebook_name.py to build/$notebook_name.html"
27+
else
28+
echo "Error: Failed to export notebook"
29+
exit 1
30+
fi

0 commit comments

Comments
 (0)