1
+ name : Build Preview Deployment
2
+
3
+ on :
4
+ pull_request :
5
+ types : [opened, synchronize]
6
+
7
+ # cancel in-progress runs on new commits to same PR (github.event.number)
8
+ concurrency :
9
+ group : ${{ github.workflow }}-${{ github.event.number || github.sha }}
10
+ cancel-in-progress : true
11
+
12
+ jobs :
13
+ build-preview :
14
+ runs-on : ubuntu-latest
15
+ name : Build Preview Site and Upload Build Artifact
16
+ steps :
17
+ - name : Checkout repository
18
+ uses : actions/checkout@v4
19
+ with :
20
+ submodules : ' recursive'
21
+
22
+ - name : Get yarn cache directory path
23
+ id : yarn-cache-dir-path
24
+ run : echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
25
+
26
+ - name : Cache Node dependencies
27
+ uses : actions/cache@v4
28
+ id : yarn-cache
29
+ with :
30
+ path : ${{ steps.yarn-cache-dir-path.outputs.dir }}
31
+ key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
32
+ restore-keys : |
33
+ ${{ runner.os }}-yarn-
34
+
35
+ - name : Cache Next Build
36
+ uses : actions/cache@v4
37
+ with :
38
+ path : |
39
+ ${{ steps.yarn-cache-dir-path.outputs.dir }}
40
+ ${{ github.workspace }}/.next/cache
41
+ key : ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
42
+ restore-keys : |
43
+ ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
44
+
45
+ - name : Setup Node.js
46
+ uses : actions/setup-node@v4
47
+ with :
48
+ node-version : 20
49
+
50
+ - name : Install dependencies
51
+ run : yarn install --frozen-lockfile
52
+
53
+ - name : Build Site
54
+ run : yarn run build
55
+ env :
56
+ NEXT_PUBLIC_ALGOLIA_APP_ID : ${{ vars.NEXT_PUBLIC_ALGOLIA_APP_ID }}
57
+ NEXT_PUBLIC_ALGOLIA_API_KEY : ${{ vars.NEXT_PUBLIC_ALGOLIA_API_KEY }}
58
+
59
+ # Uploads the build directory as a workflow artifact
60
+ - name : Upload build artifact
61
+ uses : actions/upload-artifact@v4
62
+ with :
63
+ name : preview-build
64
+ path : out
0 commit comments