From e764d6ac895578b7140976259fd4967d0fd12861 Mon Sep 17 00:00:00 2001 From: afoim Date: Wed, 13 Aug 2025 14:18:32 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=88=A0=E9=99=A4PR=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr.yml | 64 ---------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 1f44b70ec..000000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: PR Preview Deploy - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - - steps: - # 1. 拉取 PR 分支代码(支持 fork) - - name: Checkout PR branch - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - token: ${{ secrets.GITHUB_TOKEN }} - - # 2. 安装 Node.js - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - # 3. 安装依赖 - - name: Install dependencies - run: npm install - - # 4. 本地构建项目(生成 dist) - - name: Build site - run: npm run build - - # 5. 安装 Wrangler CLI(用于上传 dist) - - name: Install Wrangler CLI - run: npm install -g wrangler - - # 6. 上传 dist 目录到 Cloudflare Pages - - name: Deploy dist to Cloudflare Pages - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_PROJECT_NAME: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: | - BRANCH_NAME=pr-${PR_NUMBER} - wrangler pages deploy ./dist \ - --project-name=$CLOUDFLARE_PROJECT_NAME \ - --branch=$BRANCH_NAME - - # 7. 在 PR 评论区发布预览链接 - - name: Comment preview URL on PR - uses: actions/github-script@v7 - with: - script: | - const prNumber = context.payload.pull_request.number; - const project = process.env.CLOUDFLARE_PROJECT_NAME; - const url = `https://${project}--pr-${prNumber}.pages.dev`; - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - body: `✅ 预览已部署:${url}` - });