mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-23 18:20:40 +08:00
153
.github/workflows/CD.yaml
vendored
Normal file
153
.github/workflows/CD.yaml
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
## 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:
|
||||
|
||||
jobs:
|
||||
install-init:
|
||||
name: "依赖安装初始化"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.20.2
|
||||
|
||||
- name: PNPM Install
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7
|
||||
run_install: true
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
## 部署到Github-Pages
|
||||
deploy-github:
|
||||
name: "部署到Github-Pages"
|
||||
needs: install-init
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Restore dependencies from cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
|
||||
# 运行构建脚本
|
||||
- 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平台"
|
||||
needs: install-init
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == '142vip/408CSFamily'
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Restore dependencies from cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Pull Vercel Environment Information
|
||||
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
|
||||
|
||||
- name: Build Project Artifacts
|
||||
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||||
|
||||
- name: Deploy Project Artifacts to Vercel
|
||||
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||||
|
||||
## 版本发布
|
||||
release:
|
||||
name: "创建Github发布"
|
||||
runs-on: ubuntu-latest
|
||||
needs: install-init
|
||||
## 主库且tag更新时执行
|
||||
if: github.repository == '142vip/408CSFamily' && startsWith(github.ref, 'refs/tags/v')
|
||||
|
||||
steps:
|
||||
- name: Restore dependencies from cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
### 打成压缩包
|
||||
- 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
|
||||
116
.github/workflows/CI.yml
vendored
Normal file
116
.github/workflows/CI.yml
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
## 代码CI快速集成流水线,lint、fix、build
|
||||
|
||||
|
||||
name: CI
|
||||
## 触发条件
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'next'
|
||||
- '!pages/**'
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- next
|
||||
# 手动触发部署
|
||||
workflow_dispatch:
|
||||
|
||||
schedule:
|
||||
- cron: "0 0 1 * *"
|
||||
|
||||
jobs:
|
||||
install-init:
|
||||
name: "依赖安装初始化"
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.20.2
|
||||
|
||||
- name: PNPM Install
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7
|
||||
run_install: true
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
Base-Build:
|
||||
name: "基础编译构建"
|
||||
runs-on: ubuntu-latest
|
||||
needs: install-init
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Restore Dependencies From Cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Code LintFix
|
||||
run: ./scripts/lint --fix
|
||||
|
||||
- name: Build Site
|
||||
run: ./scripts/bundle build
|
||||
|
||||
- name: Build Site With Proxy
|
||||
run: ./scripts/bundle build_proxy
|
||||
|
||||
Build-Docker-Image:
|
||||
name: "构建Docker镜像"
|
||||
runs-on: ubuntu-latest
|
||||
needs: install-init
|
||||
## 主库且tag更新时执行
|
||||
if: github.repository == '142vip/408CSFamily' && startsWith(github.ref, 'refs/tags/v')
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Login Docker
|
||||
run: |
|
||||
docker version
|
||||
echo "-----------Docker Login-----------"
|
||||
docker login \
|
||||
--username=${{ env.UserName }} \
|
||||
--password=${{ secrets.DOCKER_PASSWORD }} \
|
||||
${{env.REGISTRY}}
|
||||
|
||||
- name: Restore Dependencies From Cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
|
||||
## 构建,支持domain
|
||||
- name: Build To Dist
|
||||
run: ./scripts/bundle build_proxy
|
||||
|
||||
- name: Push Docker Image
|
||||
run: ./scripts/bundle image_faster
|
||||
66
.github/workflows/build-docker-image.yml
vendored
66
.github/workflows/build-docker-image.yml
vendored
@@ -1,66 +0,0 @@
|
||||
# 构建Docker镜像
|
||||
name: Build-Docker-Image
|
||||
|
||||
## 触发条件
|
||||
on:
|
||||
# push:
|
||||
# branches:
|
||||
# - master
|
||||
# - next
|
||||
# Publish semver tags as releases.
|
||||
# tags: [ 'v*.*.*' ]
|
||||
# 手动触发部署
|
||||
workflow_dispatch:
|
||||
# pull_request:
|
||||
# branches:
|
||||
# - master
|
||||
# - next
|
||||
|
||||
## 环境变量
|
||||
env:
|
||||
REGISTRY: registry.cn-hangzhou.aliyuncs.com
|
||||
UserName: mmdapl
|
||||
|
||||
jobs:
|
||||
Docker-Image:
|
||||
name: "构建Docker镜像"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == '142vip/408CSFamily'
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Login Docker
|
||||
run: |
|
||||
docker version
|
||||
echo "-----------Docker Login-----------"
|
||||
docker login \
|
||||
--username=${{ env.UserName }} \
|
||||
--password=${{ secrets.DOCKER_PASSWORD }} \
|
||||
${{env.REGISTRY}}
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.20.2
|
||||
|
||||
- name: PNPM Install
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7
|
||||
run_install: true
|
||||
|
||||
## 构建,支持domain
|
||||
- name: Build To Dist
|
||||
run: ./scripts/bundle build_proxy
|
||||
|
||||
- name: Push Docker image
|
||||
run: ./scripts/bundle image_faster
|
||||
|
||||
45
.github/workflows/code-lintfix.yml
vendored
45
.github/workflows/code-lintfix.yml
vendored
@@ -1,45 +0,0 @@
|
||||
# 构建Docker镜像
|
||||
name: Code-LintFix
|
||||
|
||||
## 触发条件
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'next'
|
||||
- '!pages/**'
|
||||
# 手动触发部署
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
jobs:
|
||||
Code-CI:
|
||||
runs-on: ubuntu-latest
|
||||
# if: github.repository == '142vip/408CSFamily'
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.20.2
|
||||
|
||||
- name: PNPM Install
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7
|
||||
run_install: true
|
||||
|
||||
- name: Code Fix
|
||||
run: ./scripts/lint --fix
|
||||
|
||||
- name: Build Site
|
||||
run: ./scripts/bundle build
|
||||
87
.github/workflows/esc-deploy.yml
vendored
87
.github/workflows/esc-deploy.yml
vendored
@@ -1,87 +0,0 @@
|
||||
# 部署到服务器
|
||||
name: ESC-Deploy
|
||||
|
||||
on:
|
||||
## 推送到master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: registry.cn-hangzhou.aliyuncs.com
|
||||
UserName: mmdapl
|
||||
|
||||
jobs:
|
||||
Docker-Image:
|
||||
name: "构建Docker镜像"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == '142vip/408CSFamily'
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Login Docker
|
||||
run: |
|
||||
docker version
|
||||
echo "-----------Docker Login-----------"
|
||||
docker login \
|
||||
--username=${{ env.UserName }} \
|
||||
--password=${{ secrets.DOCKER_PASSWORD }} \
|
||||
${{env.REGISTRY}}
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.20.2
|
||||
|
||||
- name: PNPM Install
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7
|
||||
run_install: true
|
||||
|
||||
- name: Build And Push Docker image
|
||||
run: ./script/bundle image
|
||||
|
||||
Deploy-ESC:
|
||||
needs: Docker-Image
|
||||
name: "部署到ESC"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == '142vip/408CSFamily'
|
||||
permissions:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
|
||||
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 408 ${{steps.version.outputs.value}}
|
||||
43
.github/workflows/github-page-deploy.yml
vendored
43
.github/workflows/github-page-deploy.yml
vendored
@@ -1,43 +0,0 @@
|
||||
## 参考资料:https://v2.vuepress.vuejs.org/zh/guide/deployment.html#github-pages
|
||||
name: Github-Page-Deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- next
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy-github:
|
||||
name: "部署到Github"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.20.2
|
||||
|
||||
- name: PNPM Install
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7
|
||||
run_install: true
|
||||
|
||||
# 运行构建脚本
|
||||
- name: Build VuePress Site
|
||||
run: ./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 }}
|
||||
70
.github/workflows/github-version-release.yml
vendored
70
.github/workflows/github-version-release.yml
vendored
@@ -1,70 +0,0 @@
|
||||
name: Github-Version-Release
|
||||
|
||||
on:
|
||||
## 当以 'v' 开头的标签推送到master时触发工作流程
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Create Release
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == '142vip/408CSFamily'
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.20.2
|
||||
|
||||
- name: PNPM Install
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7
|
||||
run_install: true
|
||||
|
||||
### 打成压缩包
|
||||
- name: Create Zip Archive
|
||||
run: |
|
||||
zip -r 408CSFamily.zip . \
|
||||
-x "node_modules/*"
|
||||
|
||||
# 提取版本号
|
||||
- name: Extract Version
|
||||
id: extract_version
|
||||
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
|
||||
|
||||
|
||||
# 创建发布版本
|
||||
- name: Create 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: Release v${{ steps.extract_version.outputs.version }}
|
||||
body: |
|
||||
|
||||
### Features
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
## 更新资源
|
||||
- name: Upload 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
|
||||
28
.github/workflows/vercel-deploy.yml
vendored
28
.github/workflows/vercel-deploy.yml
vendored
@@ -1,28 +0,0 @@
|
||||
# 自动部署到vercel上
|
||||
name: Vercel Deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- next
|
||||
# pull_request:
|
||||
# branches:
|
||||
# - master
|
||||
# - next
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
|
||||
fetch-depth: 0
|
||||
|
||||
- name: sync to vercel
|
||||
uses: amondnet/vercel-action@v20
|
||||
with:
|
||||
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
||||
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
|
||||
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
|
||||
Reference in New Issue
Block a user