From 015752e16dc7fe95ae2e0475c970b08a297af588 Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 23 Nov 2024 12:20:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?ci:=20=E6=94=B9=E7=94=A8=20wrangler-action@?= =?UTF-8?q?v3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cf.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cf.yml b/.github/workflows/cf.yml index d367bb0..d991118 100644 --- a/.github/workflows/cf.yml +++ b/.github/workflows/cf.yml @@ -37,15 +37,18 @@ jobs: - name: 构建项目 run: pnpm run build # 构建 VitePress 项目 - # 第五步:安装 Wrangler - - name: 安装 Wrangler - run: pnpm add -g wrangler@3 # 安装 Wrangler v3 - - # 第六步:发布到 Cloudflare Pages - - name: 发布到 Cloudflare Pages - uses: cloudflare/pages-action@v1 + - name: Deploy + uses: cloudflare/wrangler-action@v3 with: - apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} # Cloudflare Pages API Token - accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} # Cloudflare 账户 ID - projectName: blog # Cloudflare Pages 项目名称 - directory: docs/.vitepress/dist # 构建输出目录 + apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} + command: pages deploy docs/.vitepress/dist --project-name=blog + + # # 第六步:发布到 Cloudflare Pages + # - name: 发布到 Cloudflare Pages + # uses: cloudflare/pages-action@v1 + # with: + # apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} # Cloudflare Pages API Token + # accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} # Cloudflare 账户 ID + # projectName: blog # Cloudflare Pages 项目名称 + # directory: docs/.vitepress/dist # 构建输出目录 From 9af299119d43cb6b41c858dbc06285819d670e16 Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 23 Nov 2024 12:38:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0=E9=A2=84=E8=A7=88?= =?UTF-8?q?=20PR=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/preview-pr-build.yaml | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/preview-pr-build.yaml diff --git a/.github/workflows/preview-pr-build.yaml b/.github/workflows/preview-pr-build.yaml new file mode 100644 index 0000000..5324b23 --- /dev/null +++ b/.github/workflows/preview-pr-build.yaml @@ -0,0 +1,59 @@ +name: Preview PR Build + +on: + pull_request_target: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + deploy: + runs-on: ubuntu-latest + outputs: + preview_url: ${{ steps.deploy.outputs.url }} + steps: + - name: 检出主仓库代码 + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.base.ref }} + fetch-depth: 0 + submodules: true + + - name: 检出 PR 修改的部分 + run: | + git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge + git checkout -qf FETCH_HEAD + + # - name: 配置 baseURL + # run: | + # sed -i 's|baseURL = "https://mtf.wiki/"|baseURL = "/"|' config/_default/config.toml + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + + - name: Install npm dependencies + run: npm install + + - name: Set up Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: latest + extended: true + + - name: Build site + run: hugo --minify --enableGitInfo --baseURL "/" + + - name: deploy + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} + command: pages deploy docs/.vitepress/dist --project-name=blog + # 获取预览链接并发送到PR + comment_on_pr: + needs: deploy + uses: project-trans/actions/.github/workflows/comment-pr-preview-link.yml@main + secrets: inherit + with: + previewUrl: ${{ needs.deploy.outputs.preview_url }} From 7158571015b25228d846625a19232689db6ca8fe Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 23 Nov 2024 12:43:26 +0800 Subject: [PATCH 3/3] test --- docs/tips/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/tips/index.md b/docs/tips/index.md index 6e562fe..da82378 100644 --- a/docs/tips/index.md +++ b/docs/tips/index.md @@ -10,3 +10,5 @@ index: false ## 查看方式 电脑端在左侧-侧边栏查看文档,手机端点击左上角 `目录` + +测试