构建 VitePress 的 yaml 文件
# This is a workflow for Continuous Integration (CI) for a VitePress project
name: 构建VitePress文档
# Controls when the workflow will run
on:
# Trigger the workflow only on push events to the "master" branch
push:
branches:
- master # 仅在 master 分支上推送时触发
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
# A workflow run consists of one or more jobs
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks out your repository under $GITHUB_WORKSPACE, allowing access to the codebase
- name: 检查环境
uses: actions/checkout@v4
# Set up Node.js environment
- name: 安装Nodejs
uses: actions/setup-node@v4
with:
node-version: '20' # Specify the Node.js version to use
# cache: ${{ steps.detect-package-manager.outputs.manager }}
# Install project dependencies using Yarn
- name: 安装依赖
run: yarn
# Build the VitePress site
- name: 构建站点
run: yarn web:build
- name: 上传工程文件
uses: actions/upload-pages-artifact@v3
with:
path: ./.vitepress/dist
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: 部署到GitHub Pages
id: deployment
uses: actions/deploy-pages@v4