-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (76 loc) · 2.47 KB
/
www.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Build + Deploy to GitHub Pages
on:
push:
branches:
- www
workflow_call:
inputs:
ref:
type: string
default: main
description: "The branch, tag, or SHA to run the workflow from"
workflow_dispatch:
inputs:
ref:
type: string
default: main
description: "The branch, tag, or SHA to run the workflow from"
jobs:
run:
name: Build + Deploy to GitHub Pages (iff www/ has changed since last gh-pages push)
runs-on: ubuntu-latest
steps:
# See https://github.com/actions/checkout/issues/265#issuecomment-1936792528
- name: Resolve inputs.ref to full SHA
id: resolve-ref
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
ref=${{ inputs.ref }}
sha=$(gh api /repos/$GITHUB_REPOSITORY/commits/$ref | jq -r .sha)
if [ -z "$sha" ]; then
echo "Failed to resolve ref $ref (possibly missing GH_TOKEN env var?)" >&2
exit 1
fi
echo "Expanded ref $ref to SHA $sha"
echo "sha=$sha" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: ${{ steps.resolve-ref.outputs.sha }}
- 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
- name: pnpm install, build, export
if: steps.www-changed.outputs.WWW_CHANGED
env:
S3_DBS: 1
run: |
cd www
pnpm install
pnpm run gha-export
du -sh out
- 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