|
| 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: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout |
| 12 | + uses: actions/checkout@v4 |
| 13 | + - name: Setup Anaconda |
| 14 | + uses: conda-incubator/setup-miniconda@v3 |
| 15 | + with: |
| 16 | + auto-update-conda: true |
| 17 | + auto-activate-base: true |
| 18 | + miniconda-version: 'latest' |
| 19 | + python-version: "3.12" |
| 20 | + environment-file: environment.yml |
| 21 | + activate-environment: quantecon |
| 22 | + - name: Install latex dependencies |
| 23 | + run: | |
| 24 | + sudo apt-get -qq update |
| 25 | + sudo apt-get install -y \ |
| 26 | + texlive-latex-recommended \ |
| 27 | + texlive-latex-extra \ |
| 28 | + texlive-fonts-recommended \ |
| 29 | + texlive-fonts-extra \ |
| 30 | + texlive-xetex \ |
| 31 | + latexmk \ |
| 32 | + xindy \ |
| 33 | + dvipng \ |
| 34 | + cm-super |
| 35 | + - name: Display Conda Environment Versions |
| 36 | + shell: bash -l {0} |
| 37 | + run: conda list |
| 38 | + - name: Display Pip Versions |
| 39 | + shell: bash -l {0} |
| 40 | + run: pip list |
| 41 | + # Download Build Cache from cache.yml |
| 42 | + - name: Download "build" folder (cache) |
| 43 | + uses: dawidd6/action-download-artifact@v9 |
| 44 | + with: |
| 45 | + workflow: cache.yml |
| 46 | + branch: main |
| 47 | + name: build-cache |
| 48 | + path: _build |
| 49 | + # TODO: pdf support |
| 50 | + # # Build Assets (Download Notebooks, PDF via LaTeX) |
| 51 | + # - name: Build PDF from LaTeX |
| 52 | + # shell: bash -l {0} |
| 53 | + # run: | |
| 54 | + # jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going |
| 55 | + # - name: Copy LaTeX PDF for GH-PAGES |
| 56 | + # shell: bash -l {0} |
| 57 | + # run: | |
| 58 | + # mkdir -p _build/html/_pdf |
| 59 | + # cp -u _build/latex/*.pdf _build/html/_pdf |
| 60 | + # TODO: download notebook support |
| 61 | + # - name: Build Download Notebooks (sphinx-tojupyter) |
| 62 | + # shell: bash -l {0} |
| 63 | + # run: | |
| 64 | + # jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going |
| 65 | + # zip -r download-notebooks.zip _build/jupyter |
| 66 | + # - uses: actions/upload-artifact@v4 |
| 67 | + # with: |
| 68 | + # name: download-notebooks |
| 69 | + # path: download-notebooks.zip |
| 70 | + # - name: Copy Download Notebooks for GH-PAGES |
| 71 | + # shell: bash -l {0} |
| 72 | + # run: | |
| 73 | + # mkdir -p _build/html/_notebooks |
| 74 | + # cp -u _build/jupyter/*.ipynb _build/html/_notebooks |
| 75 | + # Final Build of HTML (with assets) |
| 76 | + - name: Build HTML |
| 77 | + shell: bash -l {0} |
| 78 | + run: | |
| 79 | + jb build lectures --path-output ./ -n -W --keep-going |
| 80 | + - name: Deploy website to gh-pages |
| 81 | + uses: peaceiris/actions-gh-pages@v4 |
| 82 | + with: |
| 83 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + publish_dir: _build/html/ |
| 85 | + # cname: python-programming-fa.quantecon.org |
| 86 | + # TODO: download notebook support |
| 87 | + # - name: Prepare lecture-python-programming.notebooks sync |
| 88 | + # shell: bash -l {0} |
| 89 | + # run: | |
| 90 | + # mkdir -p _build/lecture-python-programming.notebooks |
| 91 | + # cp -a _notebook_repo/. _build/lecture-python-programming.notebooks |
| 92 | + # cp _build/jupyter/*.ipynb _build/lecture-python-programming.notebooks |
| 93 | + # ls -a _build/lecture-python-programming.notebooks |
| 94 | + # - name: Commit notebooks to lecture-python-programming.notebooks |
| 95 | + # shell: bash -l {0} |
| 96 | + # env: |
| 97 | + # QE_SERVICES_PAT: ${{ secrets.QUANTECON_SERVICES_PAT }} |
| 98 | + # run: | |
| 99 | + # git clone https://quantecon-services:[email protected]/quantecon/lecture-python-programming.notebooks |
| 100 | + |
| 101 | + # cp _build/lecture-python-programming.notebooks/*.ipynb lecture-python-programming.notebooks |
| 102 | + |
| 103 | + # cd lecture-python-programming.notebooks |
| 104 | + # git config user.name "QuantEcon Services" |
| 105 | + # git config user.email "[email protected]" |
| 106 | + # git add *.ipynb |
| 107 | + # git commit -m "auto publishing updates to notebooks" |
| 108 | + # git push origin main |
0 commit comments