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 # 构建输出目录 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 }} 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 ## 查看方式 电脑端在左侧-侧边栏查看文档,手机端点击左上角 `目录` + +测试