Skip to content

Commit 893a734

Browse files
committed
feat: update release prerelease workflows
1 parent 5ac052f commit 893a734

File tree

9 files changed

+1527
-196
lines changed

9 files changed

+1527
-196
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Comment Vercel Preview'
2+
description: 'Comment Vercel deploy preview links on a PR.'
3+
inputs:
4+
inspect_url:
5+
description: 'Inspect URL from Vercel deploy output.'
6+
required: true
7+
preview_url:
8+
description: 'Preview/Production URL from Vercel deploy output.'
9+
required: true
10+
label:
11+
description: 'Label for the deployment (e.g., EN, ZH-HANS).'
12+
required: true
13+
runs:
14+
using: 'composite'
15+
steps:
16+
- name: Comment PR with Vercel Preview Links
17+
uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const inspect = process.env.INSPECT_URL;
21+
const preview = process.env.PREVIEW_URL;
22+
let body = `**Vercel Deploy Preview (${process.env.LABEL})**\n\n`;
23+
body += `- [Inspect](${inspect}) | [Preview](${preview})`;
24+
github.rest.issues.createComment({
25+
issue_number: context.issue.number,
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
body
29+
});
30+
env:
31+
INSPECT_URL: ${{ inputs.inspect_url }}
32+
PREVIEW_URL: ${{ inputs.preview_url }}
33+
LABEL: ${{ inputs.label }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Update Search Index'
2+
description: 'Build docs and update Orama search index for a given locale.'
3+
inputs:
4+
locale:
5+
description: "Locale to update (e.g., 'en' or 'zh-hans')"
6+
required: true
7+
orama_private_api_key_en:
8+
description: "Orama Private API Key for EN"
9+
required: true
10+
orama_private_api_key_zh_hans:
11+
description: "Orama Private API Key for ZH-HANS"
12+
required: true
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Build docs
17+
shell: bash
18+
run: pnpm build:docs
19+
env:
20+
LOCALE: "${{ inputs.locale }}"
21+
GEN_ORAMA_STATIC: "true"
22+
MDX_ASYNC: "true"
23+
NODE_OPTIONS: "--max-old-space-size=8192"
24+
- name: Update Search Index
25+
shell: bash
26+
run: pnpm run update-search-index
27+
env:
28+
LOCALE: "${{ inputs.locale }}"
29+
ORAMA_PRIVATE_API_KEY_EN: ${{ inputs.orama_private_api_key_en }}
30+
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ inputs.orama_private_api_key_zh_hans }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Vercel Deploy"
2+
description: "Deploy to Vercel and output preview/inspect URLs"
3+
inputs:
4+
environment:
5+
description: "Vercel environment (production or preview)"
6+
required: true
7+
prodFlag:
8+
description: "Set to --prod for production deploys, empty for preview"
9+
required: false
10+
default: ""
11+
vercel_project_id:
12+
required: true
13+
vercel_org_id:
14+
required: true
15+
vercel_token:
16+
required: true
17+
outputs:
18+
inspect_url:
19+
description: "Vercel inspect URL"
20+
value: ${{ steps.vercel_deploy.outputs.inspect_url }}
21+
prod_url:
22+
description: "Vercel preview/production URL"
23+
value: ${{ steps.vercel_deploy.outputs.prod_url }}
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: Pull Vercel Environment Information
28+
run: npx vercel pull --yes --environment=${{ inputs.environment }} --token=${{ inputs.vercel_token }}
29+
env:
30+
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
31+
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
32+
shell: bash
33+
- name: Build Project Artifacts
34+
run: npx vercel build ${{ inputs.prodFlag }} --token=${{ inputs.vercel_token }}
35+
env:
36+
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
37+
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
38+
shell: bash
39+
- name: Deploy Project Artifacts
40+
id: vercel_deploy
41+
run: |
42+
npx vercel deploy --prebuilt ${{ inputs.prodFlag }} --archive=tgz --token=${{ inputs.vercel_token }} 2>&1 | tee vercel_output.txt
43+
inspect_url=$(awk '/^Inspect:/ {print $2}' vercel_output.txt | head -n1)
44+
preview_url=$(awk '/^(Preview|Production):/ {print $2}' vercel_output.txt | head -n1)
45+
echo "inspect_url=$inspect_url" >> $GITHUB_OUTPUT
46+
echo "prod_url=$preview_url" >> $GITHUB_OUTPUT
47+
env:
48+
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
49+
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
50+
shell: bash

.github/workflows/prerelease.yml

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,50 @@
1-
name: Vercel Preview Deployment
1+
name: Prerelease
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches-ignore:
7-
- main
4+
workflow_dispatch:
5+
pull_request:
6+
types:
7+
- opened
8+
- labeled
9+
- synchronize
810

9-
jobs:
10-
deploy-en:
11-
uses: ./.github/workflows/vercel-deploy.yml
12-
with:
13-
environment: preview
14-
prodFlag: ''
15-
secrets:
16-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_EN_ID }}
17-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
18-
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
11+
permissions:
12+
pull-requests: write
13+
issues: write
1914

20-
deploy-zh-hans:
21-
uses: ./.github/workflows/vercel-deploy.yml
22-
with:
23-
environment: preview
24-
prodFlag: ''
25-
secrets:
26-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ZH_HANS_ID }}
27-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
28-
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
15+
jobs:
16+
deploy:
17+
if: contains(github.event.pull_request.labels.*.name, 'prerelease')
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
include:
22+
- name: Deploy EN
23+
locale: EN
24+
secret_project_id: VERCEL_PROJECT_EN_ID
25+
- name: Deploy ZH-HANS
26+
locale: ZH-HANS
27+
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
28+
name: ${{ matrix.name }}
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v3
32+
with:
33+
fetch-depth: 1
34+
- name: Setup Tools
35+
uses: ./.github/actions/setup
36+
- name: Deploy to Vercel (${{ matrix.locale }})
37+
id: deploy
38+
uses: ./.github/actions/vercel-deploy
39+
with:
40+
environment: preview
41+
prodFlag: ""
42+
vercel_project_id: ${{ secrets[matrix.secret_project_id] }}
43+
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }}
44+
vercel_token: ${{ secrets.VERCEL_TOKEN }}
45+
- name: Comment PR with Vercel Preview Links (${{ matrix.locale }})
46+
uses: ./.github/actions/comment-vercel-preview
47+
with:
48+
inspect_url: ${{ steps.deploy.outputs.inspect_url }}
49+
preview_url: ${{ steps.deploy.outputs.prod_url }}
50+
label: ${{ matrix.locale }}

.github/workflows/release.yml

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Vercel Production Deployment
1+
name: Release
22

33
on:
44
workflow_dispatch:
@@ -7,40 +7,37 @@ on:
77
- main
88

99
jobs:
10-
deploy-en:
11-
uses: ./.github/workflows/vercel-deploy.yml
12-
with:
13-
environment: production
14-
prodFlag: --prod
15-
secrets:
16-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_EN_ID }}
17-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
18-
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
19-
20-
update-search-index-en:
21-
needs: deploy-en
22-
uses: ./.github/workflows/update-search-index.yml
23-
with:
24-
locale: en
25-
secrets:
26-
ORAMA_PRIVATE_API_KEY_EN: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
27-
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}
28-
29-
deploy-zh-hans:
30-
uses: ./.github/workflows/vercel-deploy.yml
31-
with:
32-
environment: production
33-
prodFlag: --prod
34-
secrets:
35-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ZH_HANS_ID }}
36-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
37-
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
38-
39-
update-search-index-zh-hans:
40-
needs: deploy-zh-hans
41-
uses: ./.github/workflows/update-search-index.yml
42-
with:
43-
locale: zh-hans
44-
secrets:
45-
ORAMA_PRIVATE_API_KEY_EN: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
46-
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}
10+
deploy-and-update-index:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
include:
15+
- name: Deploy EN
16+
locale: en
17+
secret_project_id: VERCEL_PROJECT_EN_ID
18+
- name: Deploy ZH-HANS
19+
locale: zh-hans
20+
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
21+
name: ${{ matrix.name }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 1
27+
- name: Setup Tools
28+
uses: ./.github/actions/setup
29+
- name: Deploy to Vercel (${{ matrix.locale }})
30+
id: deploy
31+
uses: ./.github/workflows/vercel-deploy.yml
32+
with:
33+
environment: production
34+
prodFlag: --prod
35+
vercel_project_id: ${{ secrets[matrix.secret_project_id] }}
36+
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }}
37+
vercel_token: ${{ secrets.VERCEL_TOKEN }}
38+
- name: Update Search Index (${{ matrix.locale }})
39+
uses: ./.github/actions/update-search-index
40+
with:
41+
locale: ${{ matrix.locale }}
42+
orama_private_api_key_en: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
43+
orama_private_api_key_zh_hans: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}

.github/workflows/update-search-index.yml

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

.github/workflows/vercel-deploy.yml

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"devDependencies": {
1919
"@biomejs/biome": "^1.9.4",
2020
"@commitlint/cli": "^19.8.1",
21-
"@commitlint/config-conventional": "^19.8.1"
21+
"@commitlint/config-conventional": "^19.8.1",
22+
"vercel": "^42.1.1"
2223
},
2324
"author": "",
2425
"license": "ISC",

0 commit comments

Comments
 (0)