ymlname: pnpm 安装、构建、发布到 GitHub Pages
on:
push:
branches: [master, main]
# 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
concurrency:
# The workflow will run only once per branch
group: ci-${{ github.ref }}
# 确保在新的工作流运行时,取消正在进行的相同类型的工作流
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
# environment:
# # Name could be whatever you wish. It'll be visible publicly under the environments tab.
# # 在 Settings --> Environments 中查看
# name: note-production
# # https://github.com/marketplace/actions/vite-github-pages-deployer#61-not-releasing-the-environment
# # 字段可以为环境指定一个访问地址,方便在工作流中引用和使用
# url: ${{ steps.deployment.outputs.page_url }}
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@main
- name: 安装 pnpm
uses: pnpm/action-setup@master
with:
version: 9
- name: 使用 node.js ${{ matrix.node-version }}
uses: actions/setup-node@main
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: 安装依赖
run: pnpm install
shell: bash
- name: 构建
run: pnpm build
shell: bash
- name: 上传构建产物
uses: actions/upload-pages-artifact@main
with:
path: ./docs
# The name of the artifact to deploy 在 Actions 最下面可以看到
name: github-pages-upload-artifact
- name: 部署到 GitHub Pages
uses: actions/deploy-pages@main
with:
# The name of the artifact to deploy 必须和上面一样
artifact_name: github-pages-upload-artifact
# id 用于获取步骤: 例如获取步骤的输出 ${{ steps.[id].outputs.*** }}
# id: deployment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62