@@ -3,12 +3,10 @@ name: Build and Netlify Deploy
33on :
44  pull_request :
55    branches :
6-     - main 
7-     paths :
8-     - book/** 
9-     - requirements.txt 
10-     - .github/workflows/deploy.yml 
11-     - .github/workflows/ci_pr.yml 
6+     - theme_updates 
7+   push :
8+     branches :
9+     - theme_updates 
1210  workflow_dispatch :
1311
1412concurrency :
2523    permissions :
2624      contents : read 
2725      pull-requests : write 
28-     
26+       pushes : write 
27+ 
2928    steps :
3029    - name : Checkout current branch 
3130      uses : actions/checkout@v4 
@@ -50,160 +49,31 @@ jobs:
5049        echo false >> EXTRA_CACHE_VARS.txt  # archive 
5150        cat EXTRA_CACHE_VARS.txt 
5251
53- name : Cache page build 
54-       id : cache-html 
55-       uses : actions/cache@v4 
56-       with :
57-         path : " book/_build/html" 
58-         key : html-build-${{ github.head_ref }}-${{ hashFiles('book/**', 'requirements.txt', 'EXTRA_CACHE_VARS.txt') }} 
59- 
60-     - if : ${{ steps.cache-html.outputs.cache-hit != 'true' }} 
61-       name : Set up Python 3.11 
62-       uses : actions/setup-python@v5 
63-       id : setup-python 
64-       with :
65-         python-version : 3.11 
66- 
67-     - if : ${{ steps.cache-html.outputs.cache-hit != 'true' }} 
68-       name : Record current date for cache 
69-       run : | 
70-         echo "WEEK=$(date +%V)" >> $GITHUB_ENV 
71- 
72- if : ${{ steps.cache-html.outputs.cache-hit != 'true' }} 
73-       name : Cache virtualenv 
74-       uses : actions/cache@v4 
52+ uses : actions/setup-node@v4 
7553      with :
76-         key : venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-week${{ env.WEEK }}-${{ github.repository }} 
77-         path : .venv 
54+         node-version : 18.x 
7855
79-     - if : ${{ steps.cache-html.outputs.cache-hit != 'true' }} 
80-       name : Install dependencies 
56+     - name : Install MyST Markdown CLI 
8157      run : | 
82-         python -m venv .venv 
83-         source .venv/bin/activate 
84-         python -m pip install -r requirements.txt 
85-         echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH 
86-         echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV 
58+         npm install -g mystmd thebe-core thebe thebe-lite 
8759
88- if :  ${{ steps.cache-html.outputs.cache-hit != 'true' }} 
89-       name :  Build the book with TeachBooks 
60+ name :  Build HTML 
61+       working-directory :  ./lectures 
9062      run : | 
91-         set -o pipefail 
92-         # Build without preprocessing for PR preview 
93-         teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2) 
94-         set +o pipefail 
63+         myst build 
9564
96- name : If build failed, attempt to restore from cache 
97-       if : failure() 
98-       id : attempt-restore 
99-       uses : actions/cache/restore@v4 
65+ name : Upload build output 
66+       uses : actions/upload-pages-artifact@v3 
10067      with :
101-         key : none 
102-         path : " book/_build/html" 
103-         restore-keys : html-build-${{ github.head_ref }} 
104- 
105-     - name : Check build output 
106-       run : | 
107-         echo "Build completed. Contents of book/_build/html/:" 
108-         ls -la book/_build/html/ || echo "No build output found" 
109-         echo "Checking for index.html:" 
110-         ls -la book/_build/html/index.html || echo "No index.html found" 
68+         path : ' ./lectures/_build/html' 
11169
112- name : Create build status summary 
113-       if : always() 
114-       run : | 
115-         if [ ${{ job.status }} == 'success' ]; then 
116-           echo "✅ **Build Status**: Success" >> build_summary.md 
117-           echo "Book built successfully from branch \`${{ github.head_ref }}\`" >> build_summary.md 
118-         else 
119-           echo "**Build Status**: Failed" >> build_summary.md 
120-           if [ -n "${{ steps.attempt-restore.outputs.cache-matched-key }}" ]; then 
121-             echo "Using cached version from previous successful build" >> build_summary.md 
122-           else 
123-             echo " No cached version available" >> build_summary.md 
124-           fi 
125-         fi 
126-          
127-         if [ -s stderr.log ]; then 
128-           echo "" >> build_summary.md 
129-           echo " **Build Warnings/Errors**:" >> build_summary.md 
130-           echo '```' >> build_summary.md 
131-           cat stderr.log >> build_summary.md 
132-           echo '```' >> build_summary.md 
133-         fi 
134- 
135- name : Deploy to Netlify 
136-       if : always() && hashFiles('book/_build/html/**') != '' 
70+     - name : Preview Deploy to Netlify 
13771      uses : nwtgck/actions-netlify@v3 
13872      with :
139-         publish-dir : ' book/ _build/html/ ' 
73+         publish-dir : ' ./lectures/ _build/html' 
14074        production-branch : main 
14175        github-token : ${{ secrets.GITHUB_TOKEN }} 
142-         deploy-message : " Preview Deploy from ${{ github.head_ref }} (PR #${{ github.event.number }})" 
143-         alias : pr-${{ github.event.number }} 
144-         enable-pull-request-comment : true 
145-         enable-commit-comment : false 
146-         overwrites-pull-request-comment : true 
76+         deploy-message : " Preview Deploy from GitHub Actions" 
14777      env :
14878        NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }} 
14979        NETLIFY_SITE_ID : ${{ secrets.NETLIFY_SITE_ID }} 
150- 
151-     - name : Comment build summary on PR 
152-       if : always() 
153-       uses : actions/github-script@v7 
154-       with :
155-         script : | 
156-           const fs = require('fs'); 
157-           let summary = ''; 
158-           try { 
159-             summary = fs.readFileSync('build_summary.md', 'utf8'); 
160-           } catch (error) { 
161-             summary = '📋 Build summary not available'; 
162-           } 
163-            
164-           const body = `## 🚀 TeachBooks Build & Deploy Summary 
165- 
166-           ${summary} 
167- 
168-           --- 
169-           <details> 
170-           <summary>📖 TeachBooks Configuration</summary> 
171-            
172-           - **Branch**: \`${{ github.head_ref }}\` 
173-           - **Build Command**: \`teachbooks build book/\` 
174-           - **Preprocessing**: Disabled (PR preview) 
175-           - **Archive Banner**: Disabled (PR preview) 
176-           - **Cache**: ${{ steps.cache-html.outputs.cache-hit == 'true' && 'Hit ✅' || 'Miss ❌' }} 
177-            
178-           </details>`; 
179- 
180-           // Get existing comments 
181-           const { data: comments } = await github.rest.issues.listComments({ 
182-             owner: context.repo.owner, 
183-             repo: context.repo.repo, 
184-             issue_number: context.issue.number, 
185-           }); 
186- 
187-           // Find existing bot comment 
188-           const botComment = comments.find(comment =>  
189-             comment.user.type === 'Bot' &&  
190-             comment.body.includes('🚀 TeachBooks Build & Deploy Summary') 
191-           ); 
192- 
193-           if (botComment) { 
194-             // Update existing comment 
195-             await github.rest.issues.updateComment({ 
196-               owner: context.repo.owner, 
197-               repo: context.repo.repo, 
198-               comment_id: botComment.id, 
199-               body: body 
200-             }); 
201-           } else { 
202-             // Create new comment 
203-             await github.rest.issues.createComment({ 
204-               owner: context.repo.owner, 
205-               repo: context.repo.repo, 
206-               issue_number: context.issue.number, 
207-               body: body 
208-             }); 
209-           } 
0 commit comments