1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

chore: 添加 GitHub Actions 部署脚本
Some checks are pending
Deploy GitHub Pages / deploy (push) Waiting to run

This commit is contained in:
2025-03-12 16:44:06 +08:00
parent bb6a43749c
commit 9132a97c64

52
.github/workflows/deploy-pages.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
name: Deploy GitHub Pages
# 触发条件
on:
# 手动触发
workflow_dispatch:
# 当代码推送到主分支时触发
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# 缓存 node_modules
- name: Cache node_modules
uses: actions/cache@v3
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# 设置 Node.js 环境
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
# 安装依赖
- name: Install dependencies
run: npm install
# 构建项目
- name: Build
run: npm run build
# 部署到 GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist # 这里的 dist 是构建后的文件目录,根据实际情况修改