davinci-paper/.github/workflows/build-and-deploy.yml
.github/workflows/build-and-deploy.ymlRaw
1name: Build & Deploy Paper
2
3on:
4 push:
5 branches: ["main"]
6 workflow_dispatch:
7
8permissions:
9 contents: read
10
11concurrency:
12 group: "pages"
13 cancel-in-progress: true
14
15jobs:
16 build:
17 runs-on: ubuntu-latest
18
19 steps:
20 - name: Checkout repo
21 uses: actions/checkout@v4
22
23 - name: Install tools
24 run: |
25 sudo apt-get update
26 sudo apt-get install -y pandoc texlive-latex-recommended texlive-bibtex-extra texlive-extra-utils
27
28 - name: Convert LaTeX to Markdown
29 run: |
30 ./scripts/convert-paper.sh
31
32 - name: Build Markdown preview page
33 run: |
34 touch docs/.nojekyll
35 cat << 'EOF' > docs/index.html
36 <!DOCTYPE html>
37 <html lang="en" data-color-mode="light" data-light-theme="light" data-dark-theme="light">
38 <head>
39 <meta charset="UTF-8">
40 <meta name="viewport" content="width=device-width, initial-scale=1.0">
41 <title>DaVinci Paper (Markdown)</title>
42 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5.8.1/github-markdown.min.css">
43 <style>
44 :root {
45 color-scheme: light;
46 --fgColor-default: #1f2328;
47 --fgColor-muted: #57606a;
48 --fgColor-accent: #0969da;
49 --bgColor-default: #ffffff;
50 --bgColor-muted: #f6f8fa;
51 --borderColor-default: #d0d7de;
52 }
53 body {
54 margin: 0;
55 background: linear-gradient(180deg, #eef2f7 0%, #f6f8fa 30%, #f6f8fa 100%);
56 color: #1f2328;
57 }
58 .topbar {
59 position: sticky;
60 top: 0;
61 z-index: 2;
62 display: flex;
63 gap: 12px;
64 align-items: center;
65 padding: 12px 16px;
66 border-bottom: 1px solid #d0d7de;
67 background: rgba(255, 255, 255, 0.95);
68 backdrop-filter: blur(4px);
69 }
70 .topbar a {
71 text-decoration: none;
72 border: 1px solid #d0d7de;
73 border-radius: 6px;
74 padding: 6px 10px;
75 color: #1f2328;
76 background: #f6f8fa;
77 font: 600 14px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
78 }
79 .markdown-body {
80 box-sizing: border-box;
81 min-width: 200px;
82 max-width: 980px;
83 margin: 14px auto 24px;
84 padding: 30px 28px 40px;
85 background: #fff;
86 border: 1px solid #d0d7de;
87 border-radius: 10px;
88 box-shadow: 0 10px 24px rgba(31, 35, 40, 0.07);
89 color: #1f2328 !important;
90 font-size: 17px;
91 line-height: 1.72;
92 }
93 .markdown-body p,
94 .markdown-body li,
95 .markdown-body blockquote,
96 .markdown-body td,
97 .markdown-body th {
98 color: #1f2328 !important;
99 }
100 .markdown-body h1,
101 .markdown-body h2,
102 .markdown-body h3,
103 .markdown-body h4,
104 .markdown-body h5,
105 .markdown-body h6 {
106 color: #0f172a !important;
107 letter-spacing: -0.01em;
108 }
109 .markdown-body a {
110 color: #0969da !important;
111 }
112 .markdown-body code {
113 color: #0550ae;
114 background: #f6f8fa;
115 }
116 .markdown-body pre {
117 background: #f6f8fa;
118 border: 1px solid #d0d7de;
119 border-radius: 8px;
120 }
121 #status {
122 margin-left: auto;
123 font: 500 13px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
124 color: #57606a;
125 }
126 @media (max-width: 767px) {
127 .markdown-body {
128 margin: 0;
129 border-radius: 0;
130 border-left: none;
131 border-right: none;
132 padding: 22px 16px 30px;
133 font-size: 16px;
134 }
135 }
136 </style>
137 </head>
138 <body>
139 <div class="topbar">
140 <a href="paper.md" download>Download paper.md</a>
141 <a href="paper.md" target="_blank" rel="noopener noreferrer">Open raw markdown</a>
142 <span id="status">Loading markdown...</span>
143 </div>
144 <article id="content" class="markdown-body"></article>
145 <script src="https://cdn.jsdelivr.net/npm/marked@15.0.12/lib/marked.umd.min.js"></script>
146 <script src="https://cdn.jsdelivr.net/npm/dompurify@3.1.7/dist/purify.min.js"></script>
147 <script>
148 (async () => {
149 const status = document.getElementById('status');
150 const content = document.getElementById('content');
151 try {
152 const response = await fetch('paper.md', { cache: 'no-store' });
153 if (!response.ok) {
154 throw new Error('HTTP ' + response.status);
155 }
156 const md = await response.text();
157 marked.setOptions({ gfm: true, breaks: false });
158 const html = marked.parse(md);
159 content.innerHTML = DOMPurify.sanitize(html);
160 status.textContent = 'Loaded';
161 } catch (err) {
162 status.textContent = 'Failed to load markdown';
163 content.innerHTML = '<p>Unable to render <code>paper.md</code>.</p><p>' + err.message + '</p>';
164 }
165 })();
166 </script>
167 </body>
168 </html>
169 EOF
170
171 - name: Upload paper.md artifact
172 uses: actions/upload-artifact@v4
173 with:
174 name: paper-markdown
175 path: docs/paper.md
176 if-no-files-found: error
177
178 - name: Upload GitHub Pages artifact
179 uses: actions/upload-pages-artifact@v3
180 with:
181 path: docs
182
183 deploy:
184 runs-on: ubuntu-latest
185 needs: build
186 permissions:
187 pages: write
188 id-token: write
189 environment:
190 name: github-pages
191 url: ${{ steps.deployment.outputs.page_url }}
192
193 steps:
194 - name: Deploy to GitHub Pages
195 id: deployment
196 uses: actions/deploy-pages@v4