尝试配置 GitHub Actions
Some checks failed
Deploy VitePress site to Pages / build (push) Has been cancelled

用 Gitea 自己搓 runner 还是难度太高力,还是用 GitHub Actions 吧~ QAQ
This commit is contained in:
2026-04-22 15:31:39 +08:00
parent 6e4525a9b9
commit 39d3cae7ed

75
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,75 @@
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
#
name: Deploy VitePress site to Pages
on:
# 在针对 `main` 分支的推送上运行。如果你
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
push:
branches: [master]
# 允许你从 Actions 选项卡手动运行此工作流程
workflow_dispatch:
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: write
pages: write
id-token: write
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
group: pages
cancel-in-progress: false
jobs:
# 构建工作
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 如果未启用 lastUpdated则不需要
- uses: pnpm/action-setup@v3 # 如果使用 pnpm请取消此区域注释
with:
version: 9
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun请取消注释
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm # 或 npm / yarn
# - name: Setup Pages
# uses: actions/configure-pages@v4
- name: Install dependencies
run: pnpm ci # 或 npm install / yarn install / bun install
- name: Build with VitePress
run: pnpm docs:build # 或 npm run docs:build / yarn docs:build / bun run docs:build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .vitepress/dist
# 上传至腾讯云COS
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11' # 设置 Python 版本
- name: Setup coscmd and sdk
run: pip install coscmd
- name: Configure coscmd
env:
SECRET_ID: ${{ secrets.SECRET_ID }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
BUCKET: suan-docs-1309266774
REGION: ap-nanjing
run: coscmd config -a $SECRET_ID -s $SECRET_KEY -b $BUCKET -r $REGION
- name: Upload to COS
run: |
coscmd upload -rfs --delete .vitepress/dist/ /