first completed draft before lecture #79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Render Quarto Website | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths-ignore: | |
| - "docs/**" | |
| workflow_dispatch: | |
| concurrency: | |
| group: quarto-render-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| LANG: C | |
| LC_ALL: C | |
| PYTHONUTF8: "1" | |
| PYTHONIOENCODING: utf-8 | |
| jobs: | |
| render-html: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| if: github.actor != 'github-actions[bot]' | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| with: | |
| version: "1.9.37" | |
| - name: Setup Python for Quarto execution | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.x" | |
| cache: "pip" | |
| cache-dependency-path: requirements.txt | |
| - name: Install Python dependencies | |
| run: | | |
| set -euo pipefail | |
| python -m pip install --upgrade pip | |
| python -m pip install -r requirements.txt | |
| python -m ipykernel install --user --name python3 --display-name "Python 3" | |
| - name: Render website HTML | |
| run: | | |
| set -euo pipefail | |
| rm -rf docs | |
| quarto render --to html | |
| - name: Upload HTML render | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: rendered-html | |
| path: docs | |
| if-no-files-found: error | |
| render-pdf: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| permissions: | |
| contents: read | |
| if: github.actor != 'github-actions[bot]' | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 3 | |
| matrix: | |
| include: | |
| - target: course-outline.md | |
| artifact: pdf-course-outline | |
| - target: lecture_notes/lec1.qmd | |
| artifact: pdf-lec1 | |
| - target: lecture_notes/lec2.qmd | |
| artifact: pdf-lec2 | |
| - target: lecture_notes/lec3.qmd | |
| artifact: pdf-lec3 | |
| - target: lecture_notes/lec4.qmd | |
| artifact: pdf-lec4 | |
| - target: lecture_notes/lec5.qmd | |
| artifact: pdf-lec5 | |
| - target: lecture_notes/lec6.qmd | |
| artifact: pdf-lec6 | |
| - target: assignments/assignment1/assignment-1-questions.qmd | |
| artifact: pdf-assignment-1-questions | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Quarto and TinyTeX | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| with: | |
| version: "1.9.37" | |
| tinytex: true | |
| - name: Report PDF tools | |
| run: | | |
| set -euo pipefail | |
| quarto check | |
| command -v xelatex || true | |
| command -v lualatex || true | |
| command -v tlmgr || true | |
| - name: Setup Python for Quarto execution | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.x" | |
| cache: "pip" | |
| cache-dependency-path: requirements.txt | |
| - name: Install Python dependencies | |
| run: | | |
| set -euo pipefail | |
| python -m pip install --upgrade pip | |
| python -m pip install -r requirements.txt | |
| python -m ipykernel install --user --name python3 --display-name "Python 3" | |
| - name: Render PDF | |
| run: | | |
| set -euo pipefail | |
| rm -rf docs | |
| echo "Rendering ${{ matrix.target }}" | |
| timeout --kill-after=1m 8m quarto render "${{ matrix.target }}" --to pdf | |
| - name: Upload PDF render | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: | | |
| docs/**/*.pdf | |
| docs/**/figure-latex/** | |
| if-no-files-found: error | |
| publish-docs: | |
| runs-on: ubuntu-latest | |
| needs: [render-html, render-pdf] | |
| permissions: | |
| contents: write | |
| if: github.actor != 'github-actions[bot]' | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Replace docs with rendered HTML | |
| run: rm -rf docs | |
| - name: Download HTML render | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: rendered-html | |
| path: docs | |
| - name: Download PDF renders | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: pdf-* | |
| path: docs | |
| merge-multiple: true | |
| - name: Commit and push docs | |
| run: | | |
| set -euo pipefail | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add docs/ | |
| if git diff --staged --quiet; then | |
| echo "No rendered docs changes to commit." | |
| exit 0 | |
| fi | |
| git commit -m "Render Quarto website to docs/" | |
| git pull --rebase --autostash origin "${GITHUB_REF_NAME}" | |
| git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" | |
| git push |