Skip to content

Commit 885eab4

Browse files
committed
feat: add vercel-deploy gha
1 parent f4808fc commit 885eab4

File tree

4 files changed

+115
-2
lines changed

4 files changed

+115
-2
lines changed

.github/workflows/prerelease.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Vercel Preview Deployment
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
8+
jobs:
9+
deploy-en:
10+
uses: ./.github/workflows/vercel-deploy.yml
11+
with:
12+
environment: preview
13+
prodFlag: ''
14+
secrets:
15+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_EN_ID }}
16+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
17+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
18+
19+
deploy-zh-hans:
20+
uses: ./.github/workflows/vercel-deploy.yml
21+
with:
22+
environment: preview
23+
prodFlag: ''
24+
secrets:
25+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ZH_HANS_ID }}
26+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
27+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Vercel Production Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy-en:
10+
uses: ./.github/workflows/vercel-deploy.yml
11+
with:
12+
environment: production
13+
prodFlag: --prod
14+
secrets:
15+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_EN_ID }}
16+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
17+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
18+
19+
deploy-zh-hans:
20+
uses: ./.github/workflows/vercel-deploy.yml
21+
with:
22+
environment: production
23+
prodFlag: --prod
24+
secrets:
25+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ZH_HANS_ID }}
26+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
27+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

.github/workflows/vercel-deploy.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Vercel Deploy
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
description: "Vercel environment (production or preview)"
8+
required: true
9+
type: string
10+
prodFlag:
11+
description: "Set to --prod for production deploys, empty for preview"
12+
required: false
13+
type: string
14+
default: ""
15+
secrets:
16+
VERCEL_PROJECT_ID:
17+
required: true
18+
VERCEL_ORG_ID:
19+
required: true
20+
VERCEL_TOKEN:
21+
required: true
22+
23+
jobs:
24+
deploy:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Setup pnpm
33+
uses: pnpm/[email protected]
34+
35+
- name: Setup Node
36+
uses: actions/[email protected]
37+
with:
38+
node-version-file: .nvmrc
39+
40+
- name: Install Vercel CLI
41+
run: npm install --global vercel
42+
43+
- name: Pull Vercel Environment Information
44+
run: vercel pull --yes --environment=${{ inputs.environment }} --token=${{ secrets.VERCEL_TOKEN }}
45+
env:
46+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
47+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
48+
49+
- name: Build Project Artifacts
50+
run: vercel build ${{ inputs.prodFlag }} --token=${{ secrets.VERCEL_TOKEN }}
51+
env:
52+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
53+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
54+
55+
- name: Deploy Project Artifacts
56+
run: vercel deploy --prebuilt ${{ inputs.prodFlag }} --token=${{ secrets.VERCEL_TOKEN }}
57+
env:
58+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
59+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ yarn-error.log*
2626
# others
2727
.env*.local
2828
.env
29-
.vercel
29+
.vercel*
3030
next-env.d.ts
3131

3232
# content
33-
content2
33+
content2

0 commit comments

Comments
 (0)