xarray-tutorial icon indicating copy to clipboard operation
xarray-tutorial copied to clipboard

Add preview build functionality for PRs

Open dcherian opened this issue 2 years ago • 2 comments

dcherian avatar Jun 13 '22 02:06 dcherian

We've been using Netlify for this on other projects https://jupyterbook.org/publish/netlify.html, and it is very nice to have

It's free, but requires an email account to setup and charges a subscription for multiple team members. So we have an "uwhackweeskaccount"@gmail.com account that several people have access to. I could add the site under that same account for now or does xarray already have an email account like that for other services?

Netlify requires a bit of manual setup to connect the github app (probably similar to reviewNB), but then the action for PRs is pretty straightforward https://github.com/uwhackweek/jupyterbook-template/blob/main/.github/workflows/netlifypreview.yaml

    - name: Deploy Website Preview
      uses: nwtgck/[email protected]
      with:
        publish-dir: './book/_build/html'
        production-deploy: false
        github-token: ${{ secrets.GITHUB_TOKEN }}
        deploy-message: "Deploy from GitHub Actions"
        enable-commit-comment: false
        enable-pull-request-comment: true
        overwrites-pull-request-comment: true
        alias: deploy-preview-${{ github.event.number }}
      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
      timeout-minutes: 1

here is a simple example where each PR gets a URL to review https://github.com/snowex-hackweek/website2022/pull/23, after a certain amount of space is used up those URLs start to get overwritten i think

scottyhq avatar Jun 13 '22 19:06 scottyhq

I should clarify, the above approach is for when JupyterBook is built via github actions as is currently done. Other hosting options have integrated PR previews via GitHub Apps. But the drawback as far as I understand is that the build happens on external resources (Read-The-Docs, Netlify) rather than via the GitHub interface on the more configurable Actions runners.

scottyhq avatar Jun 13 '22 19:06 scottyhq