Skip to content

Build GitHub Pages

Build GitHub Pages #16

Workflow file for this run

name: Build GitHub Pages
on:
# 手动运行工作流程(workflow_dispatch 事件触发器配置后可以在actions下手动运行工作流)
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest #指定服务器的运行环境:最新版本ubuntu
steps:
# 使用actions/checkout@v4 库拉取代码到 ubuntu 上
- name: Checkout
uses: actions/checkout@v4
with:
# 根据网上资料查询此处可以设置为 false。https://github.com/actions/checkout
persist-credentials: false
# 设置node的版本
- name: Use Node.js
# 使用 actions/setup-node@v3 库安装 nodejs,with 提供了一个参数 node-version 表示要安装的 nodejs 版本
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'npm'
# 打包成静态文件
- name: Build
run: npm install && npm run build
# 部署到GitHub Pages - 也就是将打包内容发布到GitHub Pages
- name: Deploy
# 使用别人写好的 actions去部署(将打包文件部署到指定分支上)
uses: JamesIves/github-pages-deploy-action@v4
# 自定义环境变量
with:
# 填写打包好的目录名称路径,本项目配置在根目录
folder: dist