-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (94 loc) · 3.95 KB
/
Copy pathdeploy-pages.yml
File metadata and controls
105 lines (94 loc) · 3.95 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Export and deploy marimo notebooks to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: pip install marimo xpress numpy matplotlib pandas seaborn polars pyarrow networkx
- name: Export notebooks to HTML
run: |
mkdir -p _site
cd marimo
for f in *.py; do
name="${f%.py}"
marimo export html "$f" -o "../_site/${name}.html" -f
done
- name: Inject static-export banner into notebook pages
run: |
banner='<div style="position:sticky;top:0;z-index:10000;background:#fff3cd;border-bottom:1px solid #d1a954;padding:8px 16px;font-family:Calibri,Arial,sans-serif;font-size:13px;text-align:center;">This is a static, read-only snapshot — sliders and other controls will not respond. <a href="index.html">Back to notebook list</a> · <a href="https://github.com/fico-xpress/python-notebooks/tree/main/marimo">Run it yourself</a></div>'
cd _site
for f in *.html; do
[ "$f" = "index.html" ] && continue
python3 -c "
import sys
path = sys.argv[1]
banner = sys.argv[2]
with open(path, encoding='utf-8') as fh:
html = fh.read()
html = html.replace('<body>', '<body>' + banner, 1)
with open(path, 'w', encoding='utf-8') as fh:
fh.write(html)
" "$f" "$banner"
done
- name: Create index page
run: |
cat > _site/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Xpress Marimo Notebooks</title>
<style>
body { font-family: Calibri, Arial, sans-serif; font-size: 14pt; max-width: 700px; margin: 60px auto; line-height: 1.6; }
h1 { font-size: 20pt; }
p.note { font-size: 12pt; color: #555; }
ul { padding-left: 20px; }
li { margin: 8px 0; }
a { color: #0066cc; }
</style>
</head>
<body>
<h1>Xpress Python Notebooks (marimo)</h1>
<p class="note">These are static, read-only snapshots for browsing — sliders and other interactive controls will not respond. See the <a href="https://github.com/fico-xpress/python-notebooks/tree/main/marimo">marimo folder</a> for instructions to run them interactively (GitHub Codespaces or locally).</p>
<ul>
<li><a href="01_assignment.html">Assignment problem</a></li>
<li><a href="02_facility_location.html">Facility location</a></li>
<li><a href="03_sudoku.html">Sudoku</a></li>
<li><a href="04_portfolio_pandas.html">Portfolio optimization (pandas)</a></li>
<li><a href="05_campaign_polars.html">Campaign conversion optimization (polars)</a></li>
<li><a href="06_circle_packing.html">Circle packing</a></li>
<li><a href="07_unitcommitment_indicators.html">Electricity generation unit commitment</a></li>
<li><a href="08_markowitz_multiobj.html">Markowitz portfolio multi-objective optimization</a></li>
<li><a href="09_tsp_callbacks.html">Solving a TSP problem using callbacks</a></li>
</ul>
</body>
</html>
EOF
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
path: _site
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/deploy-pages@v4
id: deployment