Skip to content

Commit

Permalink
Create surgepreview.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyhq authored Jun 7, 2024
1 parent f7ed6fd commit 411066d
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/surgepreview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Surge Preview

on: [pull_request_target]

permissions:
pull-requests: write # allow surge-preview to create/update PR comments

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
preview:
# NOTE: need required reviewers in this env to protect secrets
# https://dev.to/petrsvihlik/using-environment-protection-rules-to-secure-secrets-when-building-external-forks-with-pullrequesttarget-hci
environment: SurgePreviewPR
env:
PREVIEW_URL: https://{{repository.owner}}-{{repository.name}}-{{job.name}}-pr-{{pr.number}}.surge.sh
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: conda/conda-lock.yml
environment-name: xarray-tutorial
cache-environment: true

- name: Build JupyterBook
run: |
jupyter-book build ./ --warningiserror --keep-going
- name: Dump Build Logs
if: always()
run: |
if (test -a _build/html/reports/*log); then cat _build/html/reports/*log ; fi
- name: Install Surge.sh
uses: actions/setup-node@v4

- run: npm install -g surge

- run: surge ./_build/html {{env.PREVIEW_URL}} --token $SURGE_TOKEN
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}

- name: Add URL to Summary
run: |
echo "#### :rocket: Preview deployed at {{env.PREVIEW_URL}}" >> $GITHUB_STEP_SUMMARY

0 comments on commit 411066d

Please sign in to comment.