|
| 1 | +name: Build Project [using jupyter-book] |
| 2 | +on: [push] |
| 3 | +jobs: |
| 4 | + deploy-runner: |
| 5 | + runs-on: ubuntu-latest |
| 6 | + steps: |
| 7 | + - uses: iterative/setup-cml@v1 |
| 8 | + - uses: actions/checkout@v3 |
| 9 | + with: |
| 10 | + ref: ${{ github.event.pull_request.head.sha }} |
| 11 | + - name: Deploy runner on EC2 |
| 12 | + env: |
| 13 | + REPO_TOKEN: ${{ secrets.QUANTECON_SERVICES_PAT }} |
| 14 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 15 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 16 | + run: | |
| 17 | + cml runner launch \ |
| 18 | + --cloud=aws \ |
| 19 | + --cloud-region=us-west-2 \ |
| 20 | + --cloud-type=p2.xlarge \ |
| 21 | + --labels=cml-gpu |
| 22 | + preview: |
| 23 | + needs: deploy-runner |
| 24 | + runs-on: [self-hosted, cml-gpu] |
| 25 | + container: |
| 26 | + image: docker://iterativeai/cml:latest-gpu |
| 27 | + options: --gpus all |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v3 |
| 30 | + with: |
| 31 | + ref: ${{ github.event.pull_request.head.sha }} |
| 32 | + - name: Setup Anaconda |
| 33 | + uses: conda-incubator/setup-miniconda@v2 |
| 34 | + with: |
| 35 | + auto-update-conda: true |
| 36 | + auto-activate-base: true |
| 37 | + miniconda-version: 'latest' |
| 38 | + python-version: 3.9 |
| 39 | + environment-file: environment.yml |
| 40 | + activate-environment: quantecon |
| 41 | + - name: Install latex dependencies |
| 42 | + run: | |
| 43 | + sudo apt-get -qq update |
| 44 | + sudo apt-get install -y \ |
| 45 | + texlive-latex-recommended \ |
| 46 | + texlive-latex-extra \ |
| 47 | + texlive-fonts-recommended \ |
| 48 | + texlive-fonts-extra \ |
| 49 | + texlive-xetex \ |
| 50 | + latexmk \ |
| 51 | + xindy |
| 52 | + - name: Display Conda Environment Versions |
| 53 | + shell: bash -l {0} |
| 54 | + run: conda list |
| 55 | + - name: Display Pip Versions |
| 56 | + shell: bash -l {0} |
| 57 | + run: pip list |
| 58 | + - name: Download "build" folder (cache) |
| 59 | + uses: dawidd6/action-download-artifact@v2 |
| 60 | + with: |
| 61 | + workflow: cache.yml |
| 62 | + branch: main |
| 63 | + name: build-cache |
| 64 | + path: _build |
| 65 | + # Build Assets (Download Notebooks and PDF via LaTeX) |
| 66 | + - name: Build Download Notebooks (sphinx-tojupyter) |
| 67 | + shell: bash -l {0} |
| 68 | + run: | |
| 69 | + jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going |
| 70 | + mkdir -p _build/html/_notebooks |
| 71 | + cp -u _build/jupyter/*.ipynb _build/html/_notebooks |
| 72 | + - name: Build PDF from LaTeX |
| 73 | + shell: bash -l {0} |
| 74 | + run: | |
| 75 | + jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going |
| 76 | + mkdir _build/html/_pdf |
| 77 | + cp -u _build/latex/*.pdf _build/html/_pdf |
| 78 | + # Final Build of HTML |
| 79 | + - name: Build HTML |
| 80 | + shell: bash -l {0} |
| 81 | + run: | |
| 82 | + jb build lectures --path-output ./ -n -W --keep-going |
| 83 | + - name: Preview Deploy to Netlify |
| 84 | + |
| 85 | + with: |
| 86 | + publish-dir: '_build/html/' |
| 87 | + production-branch: main |
| 88 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + deploy-message: "Preview Deploy from GitHub Actions" |
| 90 | + env: |
| 91 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 92 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
0 commit comments