2025-07-18 13:14:28 +08:00

46 lines
1.4 KiB
YAML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# workflow 名称,可以自定义
name: Deploy GitHub Pages
# 触发条件:在代码 push 到 master 分支后,自动执行该 workflow
on:
push:
branches:
- main
# 任务
jobs:
build-and-deploy:
# 服务器环境:最新版 Ubuntu也可以自定义版本
runs-on: ubuntu-latest
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
# 设置 Node.js 版本
- name: Setup Node.js environment
uses: actions/setup-node@v1
with:
node-version: "18.20.3"
# 安装yarn
- name: Install yarn
run: npm i yarn -g
# 如果缓存没有命中,安装依赖
- name: Install dependencies
run: cd documents && yarn install
# 生成静态文件
- name: Build
run: cd documents && yarn docs:build
# 部署到 GitHub Pages
- name: Deploy
uses: crazy-max/ghaction-github-pages@v2
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # ACCESS_TOKEN 是创建的 Secret 名称,替换为你自己创建的名称
with:
target-branch: gh-pages # 部署到 gh-pages 分支master 分支存放的是项目源码,而 gh-pages 分支则用来存放生成的静态文件
build_dir: documents/docs/.vitepress/dist # vuepress 生成的静态文件存放的地方