Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/actions/comment-vercel-preview/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Comment Vercel Preview'
description: 'Comment Vercel deploy preview links on a PR.'
inputs:
inspect_url:
description: 'Inspect URL from Vercel deploy output.'
required: true
preview_url:
description: 'Preview/Production URL from Vercel deploy output.'
required: true
label:
description: 'Label for the deployment (e.g., EN, ZH-HANS).'
required: true
runs:
using: 'composite'
steps:
- name: Comment PR with Vercel Preview Links
uses: actions/github-script@v7
with:
script: |
const inspect = process.env.INSPECT_URL;
const preview = process.env.PREVIEW_URL;
let body = `**Vercel Deploy Preview (${process.env.LABEL})**\n\n`;
body += `- [Inspect](${inspect}) | [Preview](${preview})`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
env:
INSPECT_URL: ${{ inputs.inspect_url }}
PREVIEW_URL: ${{ inputs.preview_url }}
LABEL: ${{ inputs.label }}
30 changes: 30 additions & 0 deletions .github/actions/update-search-index/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Update Search Index'
description: 'Build docs and update Orama search index for a given locale.'
inputs:
locale:
description: "Locale to update (e.g., 'en' or 'zh-hans')"
required: true
orama_private_api_key_en:
description: "Orama Private API Key for EN"
required: true
orama_private_api_key_zh_hans:
description: "Orama Private API Key for ZH-HANS"
required: true
runs:
using: "composite"
steps:
- name: Build docs
shell: bash
run: pnpm build:docs
env:
LOCALE: "${{ inputs.locale }}"
GEN_ORAMA_STATIC: "true"
MDX_ASYNC: "true"
NODE_OPTIONS: "--max-old-space-size=8192"
- name: Update Search Index
shell: bash
run: pnpm run update-search-index
env:
LOCALE: "${{ inputs.locale }}"
ORAMA_PRIVATE_API_KEY_EN: ${{ inputs.orama_private_api_key_en }}
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ inputs.orama_private_api_key_zh_hans }}
50 changes: 50 additions & 0 deletions .github/actions/vercel-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Vercel Deploy"
description: "Deploy to Vercel and output preview/inspect URLs"
inputs:
environment:
description: "Vercel environment (production or preview)"
required: true
prodFlag:
description: "Set to --prod for production deploys, empty for preview"
required: false
default: ""
vercel_project_id:
required: true
vercel_org_id:
required: true
vercel_token:
required: true
outputs:
inspect_url:
description: "Vercel inspect URL"
value: ${{ steps.vercel_deploy.outputs.inspect_url }}
prod_url:
description: "Vercel preview/production URL"
value: ${{ steps.vercel_deploy.outputs.prod_url }}
runs:
using: "composite"
steps:
- name: Pull Vercel Environment Information
run: npx vercel pull --yes --environment=${{ inputs.environment }} --token=${{ inputs.vercel_token }}
env:
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
shell: bash
- name: Build Project Artifacts
run: npx vercel build ${{ inputs.prodFlag }} --token=${{ inputs.vercel_token }}
env:
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
shell: bash
- name: Deploy Project Artifacts
id: vercel_deploy
run: |
npx vercel deploy --prebuilt ${{ inputs.prodFlag }} --archive=tgz --token=${{ inputs.vercel_token }} 2>&1 | tee vercel_output.txt
inspect_url=$(awk '/^Inspect:/ {print $2}' vercel_output.txt | head -n1)
preview_url=$(awk '/^(Preview|Production):/ {print $2}' vercel_output.txt | head -n1)
echo "inspect_url=$inspect_url" >> $GITHUB_OUTPUT
echo "prod_url=$preview_url" >> $GITHUB_OUTPUT
env:
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
shell: bash
70 changes: 46 additions & 24 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
name: Vercel Preview Deployment
name: Pre-release

on:
workflow_dispatch:
push:
branches-ignore:
- main
workflow_dispatch:
pull_request:
types:
- opened
- labeled
- synchronize

jobs:
deploy-en:
uses: ./.github/workflows/vercel-deploy.yml
with:
environment: preview
prodFlag: ''
secrets:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_EN_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
permissions:
pull-requests: write
issues: write

deploy-zh-hans:
uses: ./.github/workflows/vercel-deploy.yml
with:
environment: preview
prodFlag: ''
secrets:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ZH_HANS_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
jobs:
deploy:
if: contains(github.event.pull_request.labels.*.name, 'prerelease')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Deploy EN
locale: EN
secret_project_id: VERCEL_PROJECT_EN_ID
- name: Deploy ZH-HANS
locale: ZH-HANS
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
name: ${{ matrix.name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Setup Tools
uses: ./.github/actions/setup
- name: Deploy to Vercel (${{ matrix.locale }})
id: deploy
uses: ./.github/actions/vercel-deploy
with:
environment: preview
prodFlag: ""
vercel_project_id: ${{ secrets[matrix.secret_project_id] }}
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }}
vercel_token: ${{ secrets.VERCEL_TOKEN }}
- name: Comment PR with Vercel Preview Links (${{ matrix.locale }})
uses: ./.github/actions/comment-vercel-preview
with:
inspect_url: ${{ steps.deploy.outputs.inspect_url }}
preview_url: ${{ steps.deploy.outputs.prod_url }}
label: ${{ matrix.locale }}
73 changes: 35 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Vercel Production Deployment
name: Release

on:
workflow_dispatch:
Expand All @@ -7,40 +7,37 @@ on:
- main

jobs:
deploy-en:
uses: ./.github/workflows/vercel-deploy.yml
with:
environment: production
prodFlag: --prod
secrets:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_EN_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

update-search-index-en:
needs: deploy-en
uses: ./.github/workflows/update-search-index.yml
with:
locale: en
secrets:
ORAMA_PRIVATE_API_KEY_EN: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}

deploy-zh-hans:
uses: ./.github/workflows/vercel-deploy.yml
with:
environment: production
prodFlag: --prod
secrets:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ZH_HANS_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

update-search-index-zh-hans:
needs: deploy-zh-hans
uses: ./.github/workflows/update-search-index.yml
with:
locale: zh-hans
secrets:
ORAMA_PRIVATE_API_KEY_EN: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}
deploy-and-update-index:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Deploy EN
locale: en
secret_project_id: VERCEL_PROJECT_EN_ID
- name: Deploy ZH-HANS
locale: zh-hans
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
name: ${{ matrix.name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Setup Tools
uses: ./.github/actions/setup
- name: Deploy to Vercel (${{ matrix.locale }})
id: deploy
uses: ./.github/workflows/vercel-deploy.yml
with:
environment: production
prodFlag: --prod
vercel_project_id: ${{ secrets[matrix.secret_project_id] }}
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }}
vercel_token: ${{ secrets.VERCEL_TOKEN }}
- name: Update Search Index (${{ matrix.locale }})
uses: ./.github/actions/update-search-index
with:
locale: ${{ matrix.locale }}
orama_private_api_key_en: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
orama_private_api_key_zh_hans: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}
42 changes: 0 additions & 42 deletions .github/workflows/update-search-index.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/vercel-deploy.yml

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1"
"@commitlint/config-conventional": "^19.8.1",
"vercel": "^42.1.1"
},
"author": "",
"license": "ISC",
Expand Down
Loading