Picture.Cut.Service/.gitea/workflows/release-version.yaml

138 lines
4.9 KiB
YAML

name: 部署到生产环境
on:
release:
types:
- published
env:
IMAGE_NAME: ${{ gitea.repository_owner }}/cut.service
PROJECT_NAME: Dolphin.ExamPictureCut.HttpApi.Host
PUBLISH_PATH: marking.cut.service
# PUBLISH_HOST: 10.255.255.3
# PUBLISH_PORT: 22
ASPNETCORE_ENVIRONMENT: Production
jobs:
job1:
name: 编译发布
runs-on: linux-amd
container:
image: node:16-bullseye
volumes:
- /opt/.runner/nuget_packages:/root/.nuget/packages
env:
run_cmd: |
cd D:/marking.cut.service/publish
start dotnet Dolphin.ExamPictureCut.HttpApi.Host.dll --URLS="http://*:30000"
start dotnet Dolphin.ExamPictureCut.HttpApi.Host.dll --URLS="http://*:30001"
start dotnet Dolphin.ExamPictureCut.HttpApi.Host.dll --URLS="http://*:30002"
start dotnet Dolphin.ExamPictureCut.HttpApi.Host.dll --URLS="http://*:30003"
start dotnet Dolphin.ExamPictureCut.HttpApi.Host.dll --URLS="http://*:30004"
steps:
- name: 下载源码
uses: actions/checkout@v3
- name: 编译后端
uses: actions/aspnet@8.0
with:
project_name: ${{ env.PROJECT_NAME }}
os: win
# - name: 打包上传镜像
# uses: actions/docker@master
# with:
# registry: ${{ secrets.DOCKER_REGISTRY }}
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# image: ${{ env.IMAGE_NAME }}
# context: publish
# tags: latest,${{ gitea.ref_name }}
- name: 打包压缩
run: |
tar -zcvf marking.cut.service.tar.gz publish
- name: 发送到web站点
uses: docker://appleboy/drone-scp
with:
# 需要部署的主机地址
host: 10.255.255.3
# 主机ssh端口
port: 22
username: ${{ secrets.PUBLISH_USER_NAME }}
password: ${{ secrets.PUBLISH_PASSWORD }}
command_timeout: 2m
overwrite: true
target: /etc/nginx/wwwroot/static/marking
source: marking.cut.service.tar.gz
- name: 启动生产环境105
uses: docker://appleboy/drone-ssh
with:
host: minio.23544.com
port: 22105
username: marking
password: ${{ secrets.PUBLISH_WIN_PASSWORD }}
script: |
mkdir /d/marking.cut.service
cd /d/marking.cut.service
curl "http://localhost:5244/publish/kill?processName=Dolphin.ExamPictureCut.HttpApi.Host"
rm -rf marking.cut.service.tar.gz
curl -O https://static.w.23544.com:8843/marking/marking.cut.service.tar.gz
tar -zxvf marking.cut.service.tar.gz
# curl "http://localhost:5244/publish/run?execPath=D:/marking.cut.service/publish/Dolphin.ExamPictureCut.HttpApi.Host.exe&count=2"
echo "${{ env.run_cmd }}"
echo "${{ env.run_cmd }}"> publish/run.cmd
curl "http://localhost:5244/publish/run?execPath=D:/marking.cut.service/publish/run.cmd&count=2"
- name: 启动生产环境106
uses: docker://appleboy/drone-ssh
with:
host: minio.23544.com
port: 22106
username: marking
password: ${{ secrets.PUBLISH_WIN_PASSWORD }}
script: |
mkdir /d/marking.cut.service
cd /d/marking.cut.service
curl "http://localhost:5244/publish/kill?processName=Dolphin.ExamPictureCut.HttpApi.Host"
rm -rf marking.cut.service.tar.gz
curl -O https://static.w.23544.com:8843/marking/marking.cut.service.tar.gz
tar -zxvf marking.cut.service.tar.gz
# curl "http://localhost:5244/publish/run?execPath=D:/marking.cut.service/publish/Dolphin.ExamPictureCut.HttpApi.Host.exe&count=2"
echo "${{ env.run_cmd }}"
echo "${{ env.run_cmd }}"> publish/run.cmd
curl "http://localhost:5244/publish/run?execPath=D:/marking.cut.service/publish/run.cmd&count=2"
- name: 发送构建通知
if: ${{ always() }}
uses: actions/webhook@master
with:
urls: https://oapi.dingtalk.com/robot/send?access_token=6ddafcada8f44f4bad4a7314c4d9bd19a895ded0a1ba1afdaff5dd01a5af6781
content_type: application/json
template: |
{
"msgtype": "markdown",
"markdown": {
"title":"项目部署通知",
"text": "${{ job.status == 'success' && '✅' || '❌' }}**${{ gitea.repository }}**\n
>**构建结果**: ${{ job.status }}
>**构建详情**: [点击查看](${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }})
>**代码分支**: ${{ gitea.ref_name }}
>**提交标识**: ${{ gitea.sha }}
>**提交发起**: ${{ gitea.actor }}
"
}
}