mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-05-12 11:07:24 +08:00
feat(ci): 添加github CI流水线
This commit is contained in:
78
.github/workflows/esc-deploy.yml
vendored
Normal file
78
.github/workflows/esc-deploy.yml
vendored
Normal 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}}
|
||||
Reference in New Issue
Block a user