1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: deploy
on:
# 每当 push 到 main 分支时触发部署
# Deployment is triggered whenever a push is made to the main branch.
push:
branches:
# 手动触发部署
# Manually trigger deployment
workflow_dispatch:
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
# "Last updated time" and other git log-related information require fetching all commit records.
fetch-depth: 0
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
# 可选:缓存 crates 索引与源码,加速首次安装或版本升级
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-registry-${{ runner.os }}-stable
# 安装最新版本的 RustPress(每次都会检查并安装最新版本)
- name: Install RustPress
run: cargo install rustpress --locked
- name: Verify RustPress
run: rustpress -V
- name: Build site with RustPress
run: rustpress -m source build -o public
# 部署到外部仓库(适用于源码私有、展示页公开的场景)
# Deploy to an external repository (suitable for private source and public display pages).
- name: Deploy to external repository
uses: cpina/github-action-push-to-another-repository@v1.7.2
env:
# 需要在 GitHub Secrets 中配置此 Token (PAT),需具备目标仓库权限
# This Token (PAT) needs to be configured in GitHub Secrets with permissions for the destination repository.
API_TOKEN_GITHUB: ${{ secrets.EXTERNAL_REPOSITORY_PERSONAL_ACCESS_TOKEN }}
with:
# 构建产物所在目录
source-directory: public/
# 目标 GitHub 用户名或组织名
destination-github-username: rixingyike
# 目标仓库名
destination-repository-name: rixingyike.github.io
# 提交者邮箱
user-email: 9830131@qq.com
# 目标分支
target-branch: "main"