c/.github/workflows/deploy.yaml
2024-10-08 11:44:30 +08:00

67 lines
1.7 KiB
YAML

name: Deploy
on:
# 在针对 `main` 或 `master` 分支的推送上运行
push:
branches:
- master
- main
- github-pages
- gh-pages
# 允许我们从 Actions 选项卡手动运行此工作流程
workflow_dispatch:
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
group: pages
cancel-in-progress: false
jobs:
# 构建工作
build:
runs-on: ubuntu-latest
steps:
- name: "拉取代码"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "设置node.js的版本"
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: "配置Github Pages"
uses: actions/configure-pages@v5
- name: "安装依赖"
run: |
npm install
- name: "提取 git 信息"
uses: rlespinasse/git-commit-data-action@v1
- name: "vitepress 打包"
run: |
npm run docs:build
touch docs/.vitepress/dist/.nojekyll
- name: "上传构建"
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
# 部署工作
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: "部署"
id: deployment
uses: actions/deploy-pages@v4