mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-05 03:27:57 +08:00
87 lines
2.2 KiB
YAML
87 lines
2.2 KiB
YAML
# 部署到服务器
|
|
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 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}}
|