Skip to content

Commit a6c45bc

Browse files
authored
apply fix (#843)
1 parent af762d7 commit a6c45bc

File tree

3 files changed

+102
-87
lines changed

3 files changed

+102
-87
lines changed

.github/workflows/build-preview.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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

.github/workflows/deploy-preview.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Upload Preview Deployment
2+
on:
3+
workflow_run:
4+
workflows: ['Build Preview Deployment']
5+
types:
6+
- completed
7+
8+
permissions:
9+
actions: read
10+
deployments: write
11+
contents: read
12+
pull-requests: write
13+
14+
jobs:
15+
deploy-preview:
16+
runs-on: ubuntu-latest
17+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
18+
name: Deploy Preview to Cloudflare Pages
19+
steps:
20+
# Downloads the build directory from the previous workflow
21+
- name: Download build artifact
22+
uses: actions/download-artifact@v4
23+
id: preview-build-artifact
24+
with:
25+
name: preview-build
26+
path: build
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
run-id: ${{ github.event.workflow_run.id }}
29+
30+
- name: Deploy to Cloudflare Pages
31+
uses: AdrianGonz97/refined-cf-pages-action@v1
32+
with:
33+
apiToken: ${{ secrets.CF_API_TOKEN }}
34+
accountId: ${{ secrets.CF_ACCOUNT_ID }}
35+
githubToken: ${{ secrets.GITHUB_TOKEN }}
36+
projectName: ${{ vars.CF_PROJECT_NAME }}
37+
directory: ${{ steps.preview-build-artifact.outputs.download-path }}
38+
deploymentName: Preview

.github/workflows/preview-deployment.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)