1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-04-14 02:09:56 +08:00

Merge pull request #16 from mmdapl/master

feat(ci): 添加github CI流水线
This commit is contained in:
Rong姐姐好可爱
2023-03-03 18:12:14 +08:00
committed by GitHub
4 changed files with 181 additions and 18 deletions

38
.github/workflows/code-ci.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
# 构建Docker镜像
name: Code-CI
## 触发条件
on:
# 手动触发部署
workflow_dispatch:
pull_request:
branches:
- 'master'
- 'next'
- '!pages/**'
jobs:
Code-CI:
runs-on: ubuntu-latest
# if: github.repository == '142vip/408CSFamily'
permissions:
actions: read
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: PNPM Install
uses: pnpm/action-setup@v2
with:
version: 7
node-version: 14.20.1
run_install: true
# 缓存 pnpm 依赖
cache: pnpm
- name: Code Eslint Fix
run: pnpm lintfix
- name: Build Site
run: pnpm build

52
.github/workflows/docker-image.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
# 构建Docker镜像
name: 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 repository
uses: actions/checkout@v3
- name: Login Docker
run: |
docker version
echo "-----------Docker Login-----------"
docker login --username=${{ env.UserName }} --password=${{ secrets.DOCKER_PASSWORD }} ${{env.REGISTRY}}
- name: PNPM Install
uses: pnpm/action-setup@v2
with:
version: 7
node-version: 14.20.1
run_install: true
# 缓存 pnpm 依赖
cache: pnpm
- name: Build And Push Docker image
run: PROXY_DOMAIN=true pnpm faster-image

78
.github/workflows/esc-deploy.yml vendored Normal file
View File

@@ -0,0 +1,78 @@
# 部署到服务器
name: Deploy-ESC
on:
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 repository
uses: actions/checkout@v3
- name: Login Docker
run: |
docker version
echo "-----------Docker Login-----------"
docker login --username=${{ env.UserName }} --password=${{ secrets.DOCKER_PASSWORD }} ${{env.REGISTRY}}
- name: PNPM Install
uses: pnpm/action-setup@v2
with:
version: 7
node-version: 14.20.1
run_install: true
# 缓存 pnpm 依赖
cache: pnpm
- name: Build And Push Docker image
run: PROXY_DOMAIN=true pnpm faster-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}}

View File

@@ -1,14 +1,15 @@
name: docs-page-deploy
## 参考资料https://v2.vuepress.vuejs.org/zh/guide/deployment.html#github-pages
name: gh-deploy
on:
# 每当 push 到 next 分支时触发部署
push:
branches: [next]
# 手动触发部署
branches:
- master
- next
workflow_dispatch:
jobs:
docs:
deploy-github:
name: "部署到Github"
runs-on: ubuntu-latest
steps:
@@ -17,15 +18,13 @@ jobs:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
- name: Setup pnpm
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
# 选择要使用的 pnpm 版本
version: 7
# 使用 pnpm 安装依赖
run_install: true
- name: Setup Node.js
- name: Setup Node Version
uses: actions/setup-node@v3
with:
# 选择要使用的 node 版本
@@ -34,18 +33,14 @@ jobs:
cache: pnpm
# 运行构建脚本
- name: Build VuePress site
run: pnpm build-proxy
- name: Build VuePress Site
run:
PROXY_DOMAIN=true pnpm build
# 查看 workflow 的文档来获取更多信息
# @see https://github.com/crazy-max/ghaction-github-pages
- name: Deploy to GitHub Pages
- name: Deploy to GitHub Page
uses: crazy-max/ghaction-github-pages@v2
with:
# 部署到 gh-pages 分支
target_branch: pages/github
# 部署目录为 VuePress 的默认输出目录
build_dir: docs/.vuepress/dist
env:
# @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}