From c48d48f849489b17d265647241330434b70ff965 Mon Sep 17 00:00:00 2001 From: "yanqi.zong" Date: Fri, 23 May 2025 16:03:03 -0700 Subject: [PATCH 1/2] feat: add vercel-deploy gha --- .github/workflows/prerelease.yml | 27 +++++++++++++ .github/workflows/release.yml | 27 +++++++++++++ .github/workflows/vercel-deploy.yml | 59 +++++++++++++++++++++++++++++ .gitignore | 4 +- 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/prerelease.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/vercel-deploy.yml diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 00000000..0353dd2b --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,27 @@ +name: Vercel Preview Deployment + +on: + push: + branches-ignore: + - main + +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 }} + + 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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..ca4a6001 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Vercel Production Deployment + +on: + push: + branches: + - 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 }} + + 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 }} diff --git a/.github/workflows/vercel-deploy.yml b/.github/workflows/vercel-deploy.yml new file mode 100644 index 00000000..15ea2dc5 --- /dev/null +++ b/.github/workflows/vercel-deploy.yml @@ -0,0 +1,59 @@ +name: Vercel Deploy + +on: + workflow_call: + inputs: + environment: + description: "Vercel environment (production or preview)" + required: true + type: string + prodFlag: + description: "Set to --prod for production deploys, empty for preview" + required: false + type: string + default: "" + secrets: + VERCEL_PROJECT_ID: + required: true + VERCEL_ORG_ID: + required: true + VERCEL_TOKEN: + required: true + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Setup pnpm + uses: pnpm/action-setup@v4.1.0 + + - name: Setup Node + uses: actions/setup-node@v4.4.0 + with: + node-version-file: .nvmrc + + - name: Install Vercel CLI + run: npm install --global vercel + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=${{ inputs.environment }} --token=${{ secrets.VERCEL_TOKEN }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + + - name: Build Project Artifacts + run: vercel build ${{ inputs.prodFlag }} --token=${{ secrets.VERCEL_TOKEN }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + + - name: Deploy Project Artifacts + run: vercel deploy --prebuilt ${{ inputs.prodFlag }} --token=${{ secrets.VERCEL_TOKEN }} + env: + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} diff --git a/.gitignore b/.gitignore index ebe87cd6..03a390ba 100644 --- a/.gitignore +++ b/.gitignore @@ -26,8 +26,8 @@ yarn-error.log* # others .env*.local .env -.vercel +.vercel* next-env.d.ts # content -content2 \ No newline at end of file +content2 From 06348d97e026928c87c24a57e300fb0d7ba0877a Mon Sep 17 00:00:00 2001 From: "yanqi.zong" Date: Fri, 23 May 2025 16:14:47 -0700 Subject: [PATCH 2/2] feat: add --archive=tgz to deploy vercel --- .github/workflows/vercel-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vercel-deploy.yml b/.github/workflows/vercel-deploy.yml index 15ea2dc5..0749091f 100644 --- a/.github/workflows/vercel-deploy.yml +++ b/.github/workflows/vercel-deploy.yml @@ -53,7 +53,7 @@ jobs: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - name: Deploy Project Artifacts - run: vercel deploy --prebuilt ${{ inputs.prodFlag }} --token=${{ secrets.VERCEL_TOKEN }} + run: vercel deploy --prebuilt ${{ inputs.prodFlag }} --archive=tgz --token=${{ secrets.VERCEL_TOKEN }} env: VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}