Skip to content

fix(ci): 锁定 Node 25.9.0 / pnpm 9.15.0 并升级流水线 #250

fix(ci): 锁定 Node 25.9.0 / pnpm 9.15.0 并升级流水线

fix(ci): 锁定 Node 25.9.0 / pnpm 9.15.0 并升级流水线 #250

Workflow file for this run

# CD交付流水线
# - 部署到Github Pages
# - 部署到Vercel托管平台
# - 发布新的Github Release
# 参考资料:https://v2.vuepress.vuejs.org/zh/guide/deployment.html#github-pages
name: CD
on:
push:
branches:
- next
workflow_dispatch:
# 环境变量
env:
# vercel
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# Node / pnpm 版本与 package.json、.nvmrc 保持一致
NODE_VERSION: 25.9.0
PNPM_VERSION: 9.15.0
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
# 部署到Github-Pages
deploy-github:
name: 部署到Github-Pages
runs-on: ubuntu-24.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.repository == '142vip/JavaScriptCollection'
steps:
- name: Checkout Code
uses: actions/checkout@v5
with:
persist-credentials: false
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
# 安装 PNPM(版本与 package.json packageManager 一致)
- name: PNPM Install
uses: pnpm/action-setup@v5
with:
version: ${{ env.PNPM_VERSION }}
# 安装 Node 环境(版本与 .nvmrc / engines.node 一致)
- name: Install Node.js
uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install Dependencies
run: |
./scripts/ci
# 编译 打包成dist
- name: Build with VuePress
run: pnpm build:proxy
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: .vuepress/dist
# 部署
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
# 版本发布
release:
name: 创建Github发布
runs-on: ubuntu-24.04
# 主库next且执行release更新时执行
if: github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
steps:
- name: Checkout Code
uses: actions/checkout@v5
with:
persist-credentials: false
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
# 安装 PNPM(版本与 package.json packageManager 一致)
- name: PNPM Install
uses: pnpm/action-setup@v5
with:
version: ${{ env.PNPM_VERSION }}
# 安装 Node 环境(版本与 .nvmrc / engines.node 一致)
- name: Install Node.js
uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install Dependencies
run: |
./scripts/ci
# Github发布版本,并更新Release信息
- name: Release New Version
run: |
npx fa changelog
env:
GITHUB_TOKEN: ${{secrets.TOKEN}}
# Deploy-ESC:
# name: "部署到ESC服务器"
# needs: install-init
# runs-on: ubuntu-latest
# ## 主库master、next且执行release更新时执行
# if: github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
#
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
#
# - name: Get Current Version
# id: version
# uses: ashley-taylor/read-json-property-action@v1.0
# with:
# path: ./package.json
# property: version
#
# # 拉取镜像,更新服务
# - name: Pull Image And Update ESC
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SERVER_HOST }}
# port: ${{ secrets.SERVER_PORT }}
# username: ${{ secrets.SERVER_USERNAME }}
# password: ${{ secrets.SERVER_PASSWORD }}
# script: |
# docker images
# echo "-----------正在运行的服务--------"
# docker ps
# cd /service_env/ && git reset --hard && git pull origin main
# bash ./scripts/book_doc.deploy.sh jsc ${{steps.version.outputs.value}}