-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow config for PR preview to netlify (#8)
- Loading branch information
Showing
1 changed file
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name: Build and Deploy GitHub Pages | ||
name: Build and Deploy Jupyter-Book | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- build-jupyterbook | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
@@ -36,14 +36,20 @@ jobs: | |
shell: bash -el {0} | ||
run: conda run -n bookbuilder jupyter-book build . | ||
- name: Upload artifact to pass to GitHub Pages | ||
if: success() || failure() | ||
if: ${{ github.ref == 'refs/heads/main' && (success() || failure()) }} | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: _build/html | ||
deploy: | ||
name: Deploy to GitHub Pages | ||
- name: Upload artifact to pass to Netlify | ||
if: ${{ github.event.pull_request && (success() || failure()) }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: html-preview | ||
path: _build/html | ||
deploy-main: | ||
name: Deploy main branch to GitHub Pages | ||
needs: build | ||
if: success() || failure() | ||
if: ${{ github.ref == 'refs/heads/main' && (success() || failure()) }} | ||
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | ||
permissions: | ||
pages: write # to deploy to Pages | ||
|
@@ -58,3 +64,24 @@ jobs: | |
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
deploy-preview: | ||
name: Deploy PR preview to Netlify | ||
needs: build | ||
if: ${{ github.event.pull_request && (success() || failure()) }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: html-preview | ||
path: _build/html | ||
- name: Deploy to Netlify | ||
uses: nwtgck/[email protected] | ||
with: | ||
publish-dir: _build/html | ||
production-deploy: false | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
enable-pull-request-comment: true | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |