mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-02-03 02:23:38 +08:00
139 lines
4.3 KiB
YAML
139 lines
4.3 KiB
YAML
## CD交付流水线
|
||
## - 部署到Github Pages
|
||
## - 部署到Vercel托管平台
|
||
## - 发布新的Github Release
|
||
## 参考资料:https://v2.vuepress.vuejs.org/zh/guide/deployment.html#github-pages
|
||
|
||
name: CD
|
||
on:
|
||
push:
|
||
branches:
|
||
- master
|
||
- next
|
||
workflow_dispatch:
|
||
|
||
|
||
## vercel 环境变量
|
||
env:
|
||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||
|
||
jobs:
|
||
## 部署到Github-Pages
|
||
deploy-github:
|
||
name: "部署到Github-Pages"
|
||
runs-on: macos-latest
|
||
|
||
steps:
|
||
- name: Checkout Code
|
||
uses: actions/checkout@v4
|
||
with:
|
||
persist-credentials: false
|
||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||
fetch-depth: 0
|
||
|
||
## 依赖下载完成后,或执行思维导图编译
|
||
- name: PNPM Install
|
||
uses: pnpm/action-setup@v2
|
||
with:
|
||
version: 7
|
||
run_install: |
|
||
args: [--frozen-lockfile, --registry=https://registry.npmmirror.com]
|
||
|
||
# - name: Install Node.js
|
||
# uses: actions/setup-node@v3
|
||
# with:
|
||
# node-version: 18.18.0
|
||
# ## 淘宝镜像加速
|
||
# registry-url: 'https://registry.npmmirror.com'
|
||
# cache: 'pnpm'
|
||
|
||
# 运行构建脚本
|
||
- name: Build VuePress Site
|
||
run: ls -a && ./scripts/bundle build_proxy
|
||
|
||
- name: Deploy To GitHub Page
|
||
uses: crazy-max/ghaction-github-pages@v3
|
||
with:
|
||
target_branch: pages/github
|
||
build_dir: docs/.vuepress/dist
|
||
env:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
|
||
## 部署到vercel平台
|
||
deploy-vercel:
|
||
name: "部署到Vercel平台"
|
||
runs-on: macos-latest
|
||
if: github.repository == '142vip/408CSFamily'
|
||
steps:
|
||
- name: Checkout Code
|
||
uses: actions/checkout@v4
|
||
with:
|
||
persist-credentials: false
|
||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||
fetch-depth: 0
|
||
|
||
## 注意: 这里的操作时间vercel平台配置的命令拉取下来,执行
|
||
- name: Pull Vercel Environment Information
|
||
run: npm i vercel -g && vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
|
||
|
||
## 执行vercel平台配置的命令
|
||
- name: Build Project Artifacts
|
||
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||
|
||
## dist文件同步到vercel平台
|
||
- name: Deploy Project Artifacts to Vercel
|
||
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||
|
||
## 版本发布
|
||
release:
|
||
name: "Github版本发布"
|
||
runs-on: macos-latest
|
||
## 主库master、next且执行release更新时执行
|
||
if: github.repository == '142vip/408CSFamily' && startsWith(github.event.head_commit.message, 'chore(release):')
|
||
|
||
steps:
|
||
- name: Checkout Code
|
||
uses: actions/checkout@v4
|
||
with:
|
||
persist-credentials: false
|
||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||
fetch-depth: 0
|
||
|
||
### 打成压缩包
|
||
- name: Create Zip Package
|
||
run: |
|
||
zip -r 408CSFamily.zip . \
|
||
-x "node_modules/*"
|
||
|
||
# 提取版本号
|
||
- name: Get New Version Number
|
||
id: extract_version
|
||
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
|
||
|
||
# 创建发布版本
|
||
- name: Create New Release
|
||
id: create_release
|
||
uses: actions/create-release@latest
|
||
env:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
with:
|
||
tag_name: v${{ steps.extract_version.outputs.version }}
|
||
release_name: v${{ steps.extract_version.outputs.version }}
|
||
body: |
|
||
Release ${{ steps.extract_version.outputs.version }}
|
||
|
||
### Features
|
||
|
||
### Bug Fixes
|
||
|
||
## 更新资源
|
||
- name: Upload Resource Assets
|
||
uses: actions/upload-release-asset@latest
|
||
env:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
with:
|
||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||
asset_path: ./408CSFamily.zip
|
||
asset_name: 408CSFamily.zip
|
||
asset_content_type: application/zip |