Skip to content

Commit d2a4516

Browse files
authored
github: add action to build previews (#848)
1 parent 44151ec commit d2a4516

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/build-prev.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build Docs Preview
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
name: Build Docs Preview
9+
runs-on: ubuntu-latest
10+
env:
11+
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
12+
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
13+
ALGOLIA_SEARCH_API_KEY: ${{ secrets.ALGOLIA_SEARCH_API_KEY }}
14+
NODE_OPTIONS: --max_old_space_size=8192
15+
permissions:
16+
contents: read
17+
deployments: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: pnpm/action-setup@v4
21+
- name: Install dependencies
22+
run: pnpm install
23+
- name: Build website preview
24+
id: build
25+
run: |
26+
pnpm run build-prod 2>&1 | tee build.log
27+
continue-on-error: true
28+
- name: Upload build log artifact
29+
if: ${{ steps.build.outcome == 'failure' }}
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: build-log
33+
path: build.log
34+
- name: Comment on build failure with log link
35+
if: ${{ steps.build.outcome == 'failure' }}
36+
uses: peter-evans/create-or-update-comment@v2
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
issue-number: ${{ github.event.pull_request.number }}
40+
body: |
41+
## Build Failed
42+
The build has failed. You can review the full build logs and download the build log artifact via the [workflow run details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
43+
- name: Fail if build failed
44+
if: ${{ steps.build.outcome == 'failure' }}
45+
run: exit 1

0 commit comments

Comments
 (0)