Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #20

Closed
wants to merge 3 commits into from
Closed

test #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions .github/workflows/cf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 # 构建输出目录
59 changes: 59 additions & 0 deletions .github/workflows/preview-pr-build.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions docs/tips/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ index: false
## 查看方式

电脑端在左侧-侧边栏查看文档,手机端点击左上角 `目录`

测试
Loading