From 0d54a2b9775f2b5d68d5426952f7182dfb70dd03 Mon Sep 17 00:00:00 2001 From: ruan-cat <1219043956@qq.com> Date: Sun, 30 Jun 2024 17:54:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8E=20ci:=20=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E6=89=B9=E9=87=8F=E9=93=BE=E6=8E=A5vercel=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/use-vercel-cli-build-try-3.yaml | 2 +- .../workflows/use-vercel-cli-build-try-4.yaml | 83 +++++++++++++++++++ .../monorepo-3/src/typedoc-api/typedoc-api.md | 7 ++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/use-vercel-cli-build-try-4.yaml diff --git a/.github/workflows/use-vercel-cli-build-try-3.yaml b/.github/workflows/use-vercel-cli-build-try-3.yaml index 01df888..a7c23f0 100644 --- a/.github/workflows/use-vercel-cli-build-try-3.yaml +++ b/.github/workflows/use-vercel-cli-build-try-3.yaml @@ -12,7 +12,7 @@ env: on: push: branches: - - dev + - dev-notuse jobs: Deploy-Production: diff --git a/.github/workflows/use-vercel-cli-build-try-4.yaml b/.github/workflows/use-vercel-cli-build-try-4.yaml new file mode 100644 index 0000000..f033fa1 --- /dev/null +++ b/.github/workflows/use-vercel-cli-build-try-4.yaml @@ -0,0 +1,83 @@ +# 参考资料 +# https://vercel.com/guides/how-can-i-use-github-actions-with-vercel +# https://vercel.com/guides/how-to-alias-a-preview-deployment-using-the-cli + +name: 基于vercel命令的部署 +env: + # vercel的token + vct: ${{ secrets.vercel_token }} + + # 从教程内得知 环境变量名称必须大写 + VERCEL_ORG_ID: ${{ secrets.vercel_orgId }} + VERCEL_PROJECT_ID: ${{ secrets.vercel_projectId }} + + # vercel项目名称 + pjn: vercel-monorepo-test-1-zn20 + + # 项目路径 + p1: ./packages/monorepo-1 + p2: ./packages/proj-2-vp2-custom-components + p3: ./packages/monorepo-3 + p4: ./packages/monorepo-4 + p5: ./packages/monorepo-5 + + # 项目url + p1-url: monorepo-1.ruancat6312.top + p2-url: monorepo-2.ruancat6312.top + p3-url: monorepo-3.ruancat6312.top + p4-url: monorepo-4.ruancat6312.top + p5-url: monorepo-5.ruancat6312.top + +on: + push: + branches: + - dev + +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + + - name: 开启 corepack + run: corepack enable && corepack install + + - name: 检查pnpm版本 + run: pnpm -v + + - name: 安装整个项目的依赖 + run: pnpm i + + - name: 用npm安装vercel cli工具 + run: npm i -g vercel@latest + + - name: 检查vercel cli版本 + run: vc -v + + - name: 各子项目连接现有的vercel项目 + # 本地window使用 + # run: vc link --yes --cwd=./packages/monorepo-3 --project=vercel-monorepo-test-1-zn20 + run: | + vc link --yes --cwd=${{env.p1}} --project=${{env.pjn}} -t ${{env.vct}} + vc link --yes --cwd=${{env.p2}} --project=${{env.pjn}} -t ${{env.vct}} + vc link --yes --cwd=${{env.p3}} --project=${{env.pjn}} -t ${{env.vct}} + vc link --yes --cwd=${{env.p4}} --project=${{env.pjn}} -t ${{env.vct}} + vc link --yes --cwd=${{env.p5}} --project=${{env.pjn}} -t ${{env.vct}} + + - name: vercel生成特定.vercel/output/static目录 + # build命令仍然需要用token来运行。 + # run: vc build --yes --prod --cwd=./packages/monorepo-3 -A ./vercel.null.json + run: | + vc build --yes --prod --cwd=${{env.p1}} -A ./vercel.null.json -t ${{env.vct}} + vc build --yes --prod --cwd=${{env.p2}} -A ./vercel.null.json -t ${{env.vct}} + vc build --yes --prod --cwd=${{env.p3}} -A ./vercel.null.json -t ${{env.vct}} + vc build --yes --prod --cwd=${{env.p4}} -A ./vercel.null.json -t ${{env.vct}} + vc build --yes --prod --cwd=${{env.p5}} -A ./vercel.null.json -t ${{env.vct}} + + - name: turbo并发打包全部子项目 + run: pnpm run on-github-action-flow + + - name: 各只子项目上传文件并部署到vercel内 + run: | + url="$(vc deploy --yes --prebuilt --prod --cwd=${{env.p1}} -t ${{env.vct}})" + vc alias -t ${{env.vct}} set "$url" ${{env.p1-url}} diff --git a/packages/monorepo-3/src/typedoc-api/typedoc-api.md b/packages/monorepo-3/src/typedoc-api/typedoc-api.md index cdfc758..b7d0a45 100644 --- a/packages/monorepo-3/src/typedoc-api/typedoc-api.md +++ b/packages/monorepo-3/src/typedoc-api/typedoc-api.md @@ -21,3 +21,10 @@ 请优化上述的命令,确保以树形图的方式输出整个 `.vercel/output/static` 文件夹内的全部文件。 1. 请使用linux和window系统下都能够成功运行的命令。 + +## 优化命令 + +这个工作流有很多的 ./packages/monorepo-3 变量,请为我优化写法。 + +1. 把路径值全部提取出来,作为一个变量,便于复用。 +2. 未来我会把packages下面全部的monorepo项目,都用类似的方式部署,请改造工作流,便于我传递项目的位置变量。