This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 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 |