-
Notifications
You must be signed in to change notification settings - Fork 1
171 lines (153 loc) · 6.92 KB
/
pull-request.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Build and Deploy Static Site Preview
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup bun.sh environment
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Cache buns dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Run bun install
run: bun install --frozen-lockfile
- name: Cache .iiif/cache
uses: actions/cache@v4
with:
path: apps/iiif/.iiif/cache
key: ${{ runner.os }}-iiif-cache-${{ hashFiles('apps/iiif/.iiifrc.yml') }}
restore-keys: |
${{ runner.os }}-iiif-cache-
- name: Cache Next.js build cache
uses: actions/cache@v4
with:
path: apps/static-site/.next/cache
key: ${{ runner.os }}-iiif-cache-${{ hashFiles('**/bun.lockb') }}--${{ hashFiles('app/static-site/src/**/*.ts', 'app/static-site/src/**/*.tsx') }}
restore-keys: |
${{ runner.os }}-iiif-cache-${{ hashFiles('**/bun.lockb') }}
- name: "Cleanup Netlify folder"
run: |
ls -la ./.netlify || true
rm -rf ./.netlify || true
# This is a debug versino of the normal build.
- name: IIIF Netlify deploy (debug build)
id: netlify_iiif_debug
if: (contains(github.event.pull_request.labels.*.name, 'debug-build'))
working-directory: apps/iiif
run: |
npx [email protected] deploy \
--build \
--alias=deploy-debug-${{ github.event.number }} \
--message="Deploy preview from GitHub Actions (debug)"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_IIIF_SITE_ID }}
IIIF_PREVIEW_URL: https://deploy-debug-${{ github.event.number }}--delft-iiif.netlify.app
- name: "Cleanup Netlify folder"
run: |
ls -la ./.netlify || true
rm -rf ./.netlify || true
# This is the debug static site build.
- name: Static site Netlify deploy (debug)
id: netlify_static_site_debug
if: (contains(github.event.pull_request.labels.*.name, 'debug-build'))
run: |
npx [email protected] deploy \
--build \
--filter=static-site \
--alias=deploy-debug-${{ github.event.number }} \
--message="Deploy debug from GitHub Actions"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# This is a search-only API key (public)
NEXT_PUBLIC_IIIF_URL: https://deploy-debug-${{ github.event.number }}--delft-iiif.netlify.app
NEXT_PUBLIC_TYPESENSE_API_KEY: 8EOitKCMTbxUKPZNqUEoQS9M2RGvpkZS
NEXT_PUBLIC_TYPESENSE_HOST: 63flhve71t2un5xgp.a1.typesense.net
NEXT_PUBLIC_TYPESENSE_PORT: 443
NEXT_PUBLIC_TYPESENSE_PROTOCOL: https
NEXT_PUBLIC_TYPESENSE_COLLECTION_NAME: preview-manifests
# This is the actual IIIF build.
- name: IIIF Netlify deploy (preview)
id: netlify_iiif
if: (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-preview'))
working-directory: apps/iiif
run: |
deploy_json=$(npx [email protected] deploy \
--build \
--alias=deploy-preview-${{ github.event.number }} \
--json \
--message="Deploy preview from GitHub Actions")
preview_url=$(echo $deploy_json | jq -r '.deploy_url')
echo "preview_url=$preview_url" >> $GITHUB_OUTPUT
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_IIIF_SITE_ID }}
IIIF_PREVIEW_URL: https://deploy-preview-${{ github.event.number }}--delft-iiif.netlify.app
- name: "Cleanup Netlify folder"
run: |
ls -la ./.netlify || true
rm -rf ./.netlify || true
# This is the actual static site build.
- name: Static site Netlify deploy (preview)
id: netlify_static_site
if: (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-preview'))
run: |
deploy_json=$(npx [email protected] deploy \
--build \
--filter=static-site \
--alias=deploy-preview-${{ github.event.number }} \
--json \
--message="Deploy preview from GitHub Actions")
preview_url=$(echo $deploy_json | jq -r '.deploy_url')
echo "preview_url=$preview_url" >> $GITHUB_OUTPUT
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# This is a search-only API key (public)
NEXT_PUBLIC_IIIF_URL: https://deploy-preview-${{ github.event.number }}--delft-iiif.netlify.app
NEXT_PUBLIC_TYPESENSE_API_KEY: 8EOitKCMTbxUKPZNqUEoQS9M2RGvpkZS
NEXT_PUBLIC_TYPESENSE_HOST: 63flhve71t2un5xgp.a1.typesense.net
NEXT_PUBLIC_TYPESENSE_PORT: 443
NEXT_PUBLIC_TYPESENSE_PROTOCOL: https
NEXT_PUBLIC_TYPESENSE_COLLECTION_NAME: preview-manifests
- name: Build IIIF Search
if: (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-preview'))
working-directory: apps/static-site
run: |
bun run ./typesense-update.ts --recreate-index
env:
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_ADMIN_API_KEY }}
TYPESENSE_HOST: 63flhve71t2un5xgp.a1.typesense.net
TYPESENSE_PORT: 443
TYPESENSE_PROTOCOL: https
TYPESENSE_COLLECTION_NAME: preview-manifests
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Netlify output
- name: Create or update comment
if: (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-preview'))
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Netlify output
Static site (preview): ${{ steps.netlify_static_site.outputs.preview_url }}
IIIF (preview): ${{ steps.netlify_iiif.outputs.preview_url }}
IIIF Collection (preview): [Theseus](https://theseus-viewer.netlify.app/?iiif-content=${{ steps.netlify_iiif.outputs.preview_url }})
edit-mode: replace