Skip to content

Commit 65b7d64

Browse files
authored
feat: deploy preview on PRs (bazel-contrib#177)
1 parent 1881a5b commit 65b7d64

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name: Test
22
on:
3-
push:
4-
branches:
5-
- '*' # matches every branch that doesn't contain a '/'
6-
- '*/*' # matches every branch containing a single '/'
7-
- '**' # matches every branch
8-
- '!main' # excludes `main` (where we have the `deploy` workflow
93
pull_request:
10-
4+
# NB: by default, GH doesn't send the 'closed' event, which is used to clean up previews
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- closed
1110
jobs:
1211
build-and-deploy:
1312
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
@@ -20,11 +19,16 @@ jobs:
2019
uses: pnpm/action-setup@v2.4.1
2120
with:
2221
version: 8.6.12
22+
- name: Install node_modules
23+
run: pnpm install --frozen-lockfile
2324

2425
- name: Install required binaries
2526
run: |
2627
./install_bins.sh
2728
29+
- name: Check prettier formatting
30+
run: pnpm prettier-check
31+
2832
- name: Checkout BCR submodule
2933
run: |
3034
git submodule update --init -- data/bazel-central-registry
@@ -41,10 +45,14 @@ jobs:
4145
run: |
4246
git checkout ${{ inputs.bcrCommitHash }}
4347
44-
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
45-
run: |
46-
pnpm install --frozen-lockfile
47-
pnpm run build
48+
- name: Build 🔧 # Outputs the result to the 'build' folder.
49+
run: pnpm run build
50+
env:
51+
NEXT_PUBLIC_BASE_PATH: /bcr-ui-preview/pr-preview/pr-${{ github.event.number }}
4852

49-
- name: Check prettier formatting
50-
run: pnpm prettier-check
53+
- name: Deploy preview
54+
uses: rossjrw/pr-preview-action@9f77b1d057b494e662c50b8ca40ecc63f21e0887 # v1.6.2
55+
with:
56+
source-dir: ./out/
57+
token: ${{ secrets.BCR_UI_PREVIEW_PUBLISH }}
58+
deploy-repository: bazel-contrib/bcr-ui-preview

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const nextConfig = {
33
output: 'export',
44
reactStrictMode: true,
55
// for hosting under GitHub pages
6-
basePath: '',
6+
basePath: process.env.NEXT_PUBLIC_BASE_PATH || '',
77
// Increase timeout for generating static pages from default 60s to avoid issues like:
88
// Restarted static page generation for /modules/xxx/y.y.y because it took more than 60 seconds
99
staticPageGenerationTimeout: 600,

0 commit comments

Comments
 (0)