Vuepress 自动化部署(基于 Gitea Actions)
2025/3/15大约 2 分钟
Vuepress 自动化部署(基于 Gitea Actions)
- 环境准备
- 注册 Gitea Runner
- 创建 Gitea Actions
操作系统 Rocky Linux 9
环境准备
安装 Git、 Node 环境和 yarn4+
sudo dnf install -y git
sudo dnf module install -y nodejs:22
sudo npm install -g corepack
corepack enable
yarn init -2npm 默认全局安装位置没权限,但也不建议使用
sudo命令(待解决)
yarn init -2 初始化失败,可以采取离线安装
下载 Act Runner 二进制包
注册 Act Runner
获取注册令牌

Act Runner 一共有三个注册级别:实例级别、组织级别、存储库级别。这里用存储库级别,因为这个 Act Runner 当前仅用于 Vuepress 的构建和部署任务。不同注册级别区别如下:
- 实例级别:Runner将为实例中的所有存储库运行Job。
- 组织级别:Runner将为组织中的所有存储库运行Job。
- 存储库级别:Runner将为其所属的存储库运行Job。
创建配置文件,注册 Runner 并运行
# 生成配置
./act_runner generate-config > config.yaml
# 注册 Runner
./act_runner register --no-interactive --instance https://gitea.mtfh.cc --token XXXxxxXXx --name vuepress-builder --config config.yaml
# 启动 Runner
./act_runner daemon --config config.yaml使用 systemd 管理 Act Runner, 配置示例
[Unit]
Description=Gitea Act Runner
After=syslog.target
After=network.target
[Service]
RestartSec=2s
Type=simple
User=happilys
Group=happilys
WorkingDirectory=/home/happilys
ExecStart=/home/happilys/act_runner daemon --config /home/happilys/config.yaml
Restart=always
[Install]
WantedBy=multi-user.target创建 Gitea Actions
创建 .gitea/workflow/xxx.ymal 文件(Gitea 从该文件中获取任务,Action 语法同 Github Actions)如下:
name: Build docs automatically
run-name: ${{ gitea.actor }} 🚀
on:
push:
branches:
- main
jobs:
Build-Docs-and-Deploy-It:
runs-on: linux-amd64
steps:
- name: Check out repository code
uses: https://gitea.com/actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOYKEY }}
ssh-known-hosts: ssh-keyscan gitea.mtfh.cc
submodules: true
- run: yarn install
- run: yarn docs:build
- run: cp -r ./src/.vuepress/dist/* /var/www/html
actions/checkout@v4由于某些原因不能直接从 Github 获取,根据官方文档使用 Gitea 官方仓库
关于脚本中 secrets.DEPLOYKEY 变量的配置如下:
- 生成 ssh 密钥对,
ssh-keygen一路回车
ssh-keygen -t ed25519 -C "deploy@mtfh.cc" -f ~/Downloads/id_ed25519
2. Actions 密钥管理添加密钥,添加上一步生成的私钥(文件名为 id_rsa)

为需要访问的仓库添加部署密钥

gitea-repository-add-deploy-key action/checkout@v4如果配置 ssh-key 默认走 git 协议,所以虽然 vuepress-starter 是公开仓库,也许要添加部署密钥
blog-repositories
提交并推送

