|
| 1 | +name: Build & Publish to GH Pages |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'publish*' |
| 6 | +jobs: |
| 7 | + publish: |
| 8 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 9 | + runs-on: quantecon-gpu |
| 10 | + container: |
| 11 | + image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-10-py312-b |
| 12 | + options: --gpus all |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + - name: Install Git (required to commit notebooks) |
| 17 | + shell: bash -l {0} |
| 18 | + run: apt-get install -y git |
| 19 | + - name: Check nvidia drivers |
| 20 | + shell: bash -l {0} |
| 21 | + run: | |
| 22 | + nvidia-smi |
| 23 | + - name: Display Conda Environment Versions |
| 24 | + shell: bash -l {0} |
| 25 | + run: conda list |
| 26 | + - name: Display Pip Versions |
| 27 | + shell: bash -l {0} |
| 28 | + run: pip list |
| 29 | + # Download Build Cache from cache.yml |
| 30 | + - name: Download "build" folder (cache) |
| 31 | + uses: dawidd6/action-download-artifact@v7 |
| 32 | + with: |
| 33 | + workflow: cache.yml |
| 34 | + branch: main |
| 35 | + name: build-cache |
| 36 | + path: _build |
| 37 | + # Build Assets (Download Notebooks, PDF via LaTeX) |
| 38 | + - name: Build PDF from LaTeX |
| 39 | + shell: bash -l {0} |
| 40 | + run: | |
| 41 | + jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going |
| 42 | + - name: Copy LaTeX PDF for GH-PAGES |
| 43 | + shell: bash -l {0} |
| 44 | + run: | |
| 45 | + mkdir -p _build/html/_pdf |
| 46 | + cp -u _build/latex/*.pdf _build/html/_pdf |
| 47 | + - name: Build Download Notebooks (sphinx-tojupyter) |
| 48 | + shell: bash -l {0} |
| 49 | + run: | |
| 50 | + jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going |
| 51 | + zip -r download-notebooks.zip _build/jupyter |
| 52 | + - uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: download-notebooks |
| 55 | + path: download-notebooks.zip |
| 56 | + - name: Copy Download Notebooks for GH-PAGES |
| 57 | + shell: bash -l {0} |
| 58 | + run: | |
| 59 | + mkdir -p _build/html/_notebooks |
| 60 | + cp -u _build/jupyter/*.ipynb _build/html/_notebooks |
| 61 | + # Final Build of HTML (with assets) |
| 62 | + - name: Build HTML |
| 63 | + shell: bash -l {0} |
| 64 | + run: | |
| 65 | + jb build lectures --path-output ./ -n -W --keep-going |
| 66 | + - name: Deploy website to gh-pages |
| 67 | + uses: peaceiris/actions-gh-pages@v4 |
| 68 | + with: |
| 69 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + publish_dir: _build/html/ |
| 71 | + cname: python.quantecon.org |
| 72 | + - name: Prepare lecture-python.notebooks sync |
| 73 | + shell: bash -l {0} |
| 74 | + run: | |
| 75 | + mkdir -p _build/lecture-python.notebooks |
| 76 | + cp -a _notebook_repo/. _build/lecture-python.notebooks |
| 77 | + cp _build/jupyter/*.ipynb _build/lecture-python.notebooks |
| 78 | + ls -a _build/lecture-python.notebooks |
| 79 | + - name: Commit notebooks to lecture-python.notebooks |
| 80 | + shell: bash -l {0} |
| 81 | + env: |
| 82 | + QE_SERVICES_PAT: ${{ secrets.QUANTECON_SERVICES_PAT }} |
| 83 | + run: | |
| 84 | + git clone https://quantecon-services:$QE_SERVICES_PAT@github.com/quantecon/lecture-python.notebooks |
| 85 | +
|
| 86 | + cp _build/lecture-python.notebooks/*.ipynb lecture-python.notebooks |
| 87 | +
|
| 88 | + cd lecture-python.notebooks |
| 89 | + git config user.name "QuantEcon Services" |
| 90 | + git config user.email "admin@quantecon.org" |
| 91 | + git add *.ipynb |
| 92 | + git commit -m "auto publishing updates to notebooks" |
| 93 | + git push origin main |
0 commit comments