Build + Deploy to GitHub Pages #260
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
name: Build + Deploy to GitHub Pages | |
on: | |
push: | |
branches: | |
- www | |
workflow_call: | |
workflow_dispatch: | |
jobs: | |
run: | |
name: Build + Deploy to GitHub Pages (iff www/ has changed since last gh-pages push) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- run: git fetch origin gh-pages | |
- id: base-sha | |
run: echo "BASE_SHA=$(./parse-ghp-base-sha.py -d root origin/gh-pages)" >> $GITHUB_OUTPUT | |
- name: Check whether www was changed | |
id: www-changed | |
env: | |
BASE_SHA: ${{ steps.base-sha.outputs.BASE_SHA }} | |
run: | | |
echo "BASE_SHA: $BASE_SHA" | |
git fetch --depth 1 origin $BASE_SHA | |
echo "WWW_CHANGED=$([ $BASE_SHA != 'root' ] && git diff --quiet $BASE_SHA && echo '' || echo 'true')" >> $GITHUB_OUTPUT | |
- run: | | |
echo "WWW_CHANGED: ${{ steps.www-changed.outputs.WWW_CHANGED }}" | |
- if: steps.www-changed.outputs.WWW_CHANGED | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
cache: 'pnpm' | |
cache-dependency-path: www/pnpm-lock.yaml | |
- if: steps.www-changed.outputs.WWW_CHANGED | |
name: pnpm install, build, export | |
run: | | |
cd www | |
pnpm install | |
pnpm run gha-export | |
- if: steps.www-changed.outputs.WWW_CHANGED | |
name: Deploy to GH Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: www/out |