Skip to content

Commit

Permalink
Add workflow config for PR preview to netlify (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
smithara authored Aug 14, 2024
1 parent 733d6fb commit ad4d479
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/publish.yml
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:
Expand Down Expand Up @@ -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
Expand All @@ -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 }}

0 comments on commit ad4d479

Please sign in to comment.