1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
Files
tutorials/.github/workflows/deploy-pages.yml
程序员小墨 2fcd7a5f8e
Some checks are pending
Deploy GitHub Pages / deploy (push) Waiting to run
chore: 修复 GitHub Actions 打包命令错误
2025-03-13 15:54:59 +08:00

53 lines
1.2 KiB
YAML

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 是构建后的文件目录,根据实际情况修改