Skip to content

德国 | 生效后的 self-id 具体实施细节 #146

德国 | 生效后的 self-id 具体实施细节

德国 | 生效后的 self-id 具体实施细节 #146

name: Preview PR Build
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'content/**'
- 'config/**'
- 'static/**'
- 'themes/**'
- 'package.json'
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 to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }}
projectName: mtfwiki-preview
directory: public
# 获取预览链接并发送到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 }}