staging #5
|
|
@ -0,0 +1,88 @@
|
||||||
|
name: 部署到开发环境
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ${{ gitea.repository_owner }}/cut.service
|
||||||
|
PROJECT_NAME: Dolphin.ExamPictureCut.HttpApi.Host
|
||||||
|
PUBLISH_PATH: marking.cut.service
|
||||||
|
PUBLISH_HOST: 10.255.255.44
|
||||||
|
PUBLISH_PORT: 22
|
||||||
|
ASPNETCORE_ENVIRONMENT: Development
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
job1:
|
||||||
|
runs-on: linux-amd
|
||||||
|
container:
|
||||||
|
image: node:16-bullseye
|
||||||
|
volumes:
|
||||||
|
- /opt/.runner/nuget_packages:/root/.nuget/packages
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 下载源码
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 编译后端
|
||||||
|
uses: actions/aspnet@master
|
||||||
|
with:
|
||||||
|
project_name: ${{ env.PROJECT_NAME }}
|
||||||
|
|
||||||
|
- 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: 复制发布脚本
|
||||||
|
uses: docker://appleboy/drone-scp
|
||||||
|
with:
|
||||||
|
host: ${{ env.PUBLISH_HOST }}
|
||||||
|
port: ${{ env.PUBLISH_PORT }}
|
||||||
|
username: ${{ secrets.PUBLISH_USER_NAME }}
|
||||||
|
password: ${{ secrets.PUBLISH_PASSWORD }}
|
||||||
|
source: docker-compose.yaml
|
||||||
|
target: ${{ env.PUBLISH_PATH }}
|
||||||
|
|
||||||
|
- name: 部署到服务器
|
||||||
|
uses: docker://appleboy/drone-ssh
|
||||||
|
with:
|
||||||
|
host: ${{ env.PUBLISH_HOST }}
|
||||||
|
port: ${{ env.PUBLISH_PORT }}
|
||||||
|
username: ${{ secrets.PUBLISH_USER_NAME }}
|
||||||
|
password: ${{ secrets.PUBLISH_PASSWORD }}
|
||||||
|
script: |
|
||||||
|
|
||||||
|
#拉取更新
|
||||||
|
cd ${{ env.PUBLISH_PATH }}
|
||||||
|
echo 'REGISTRY=${{ secrets.DOCKER_REGISTRY }}'>.env
|
||||||
|
echo 'OWNER=${{ gitea.repository_owner }}'>>.env
|
||||||
|
echo 'TAG=${{ gitea.ref_name }}'>>.env
|
||||||
|
echo 'ASPNETCORE_ENVIRONMENT=${{ env.ASPNETCORE_ENVIRONMENT }}'>>.env
|
||||||
|
docker stack deploy -c docker-compose.yaml --with-registry-auth mk
|
||||||
|
|
||||||
|
- name: 发送构建通知
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: actions/webhook@master
|
||||||
|
with:
|
||||||
|
urls: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fd8e4bfb-a906-4601-9894-e166b3ecedda
|
||||||
|
content_type: application/json
|
||||||
|
template: |
|
||||||
|
{
|
||||||
|
"msgtype": "markdown",
|
||||||
|
"markdown": {
|
||||||
|
"content": "${{ job.status == 'success' && '✅' || '❌' }}**${{ gitea.repository }}**
|
||||||
|
>**构建结果**: ${{ job.status }}
|
||||||
|
>**构建详情**: [点击查看](${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }})
|
||||||
|
>**代码分支**: ${{ gitea.ref_name }}
|
||||||
|
>**提交标识**: ${{ gitea.sha }}
|
||||||
|
>**提交发起**: ${{ gitea.actor}}
|
||||||
|
"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
name: 部署到测试环境
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- staging
|
||||||
|
|
||||||
|
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: Staging
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
job1:
|
||||||
|
runs-on: linux-amd
|
||||||
|
container:
|
||||||
|
image: node:16-bullseye
|
||||||
|
volumes:
|
||||||
|
- /opt/.runner/nuget_packages:/root/.nuget/packages
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 下载源码
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 编译后端
|
||||||
|
uses: actions/aspnet@master
|
||||||
|
with:
|
||||||
|
project_name: ${{ env.PROJECT_NAME }}
|
||||||
|
|
||||||
|
- 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: 复制发布脚本
|
||||||
|
uses: docker://appleboy/drone-scp
|
||||||
|
with:
|
||||||
|
host: ${{ env.PUBLISH_HOST }}
|
||||||
|
port: ${{ env.PUBLISH_PORT }}
|
||||||
|
username: ${{ secrets.PUBLISH_USER_NAME }}
|
||||||
|
password: ${{ secrets.PUBLISH_PASSWORD }}
|
||||||
|
source: docker-compose.yaml
|
||||||
|
target: ${{ env.PUBLISH_PATH }}
|
||||||
|
|
||||||
|
- name: 部署到服务器
|
||||||
|
uses: docker://appleboy/drone-ssh
|
||||||
|
with:
|
||||||
|
host: ${{ env.PUBLISH_HOST }}
|
||||||
|
port: ${{ env.PUBLISH_PORT }}
|
||||||
|
username: ${{ secrets.PUBLISH_USER_NAME }}
|
||||||
|
password: ${{ secrets.PUBLISH_PASSWORD }}
|
||||||
|
script: |
|
||||||
|
|
||||||
|
#拉取更新
|
||||||
|
cd ${{ env.PUBLISH_PATH }}
|
||||||
|
echo 'REGISTRY=${{ secrets.DOCKER_REGISTRY }}'>.env
|
||||||
|
echo 'OWNER=${{ gitea.repository_owner }}'>>.env
|
||||||
|
echo 'TAG=${{ gitea.ref_name }}'>>.env
|
||||||
|
echo 'ASPNETCORE_ENVIRONMENT=${{ env.ASPNETCORE_ENVIRONMENT }}'>>.env
|
||||||
|
docker stack deploy -c docker-compose.yaml --with-registry-auth mk
|
||||||
|
|
||||||
|
- name: 发送构建通知
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: actions/webhook@master
|
||||||
|
with:
|
||||||
|
urls: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fd8e4bfb-a906-4601-9894-e166b3ecedda
|
||||||
|
content_type: application/json
|
||||||
|
template: |
|
||||||
|
{
|
||||||
|
"msgtype": "markdown",
|
||||||
|
"markdown": {
|
||||||
|
"content": "${{ job.status == 'success' && '✅' || '❌' }}**${{ gitea.repository }}**
|
||||||
|
>**构建结果**: ${{ job.status }}
|
||||||
|
>**构建详情**: [点击查看](${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }})
|
||||||
|
>**代码分支**: ${{ gitea.ref_name }}
|
||||||
|
>**提交标识**: ${{ gitea.sha }}
|
||||||
|
>**提交发起**: ${{ gitea.actor}}
|
||||||
|
"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
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:
|
||||||
|
runs-on: linux-amd
|
||||||
|
container:
|
||||||
|
image: node:16-bullseye
|
||||||
|
volumes:
|
||||||
|
- /opt/.runner/nuget_packages:/root/.nuget/packages
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 下载源码
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 编译后端
|
||||||
|
uses: actions/aspnet@master
|
||||||
|
with:
|
||||||
|
project_name: ${{ env.PROJECT_NAME }}
|
||||||
|
|
||||||
|
- 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.PWD_105 }}
|
||||||
|
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"
|
||||||
|
|
||||||
|
- name: 启动生产环境106
|
||||||
|
uses: docker://appleboy/drone-ssh
|
||||||
|
with:
|
||||||
|
host: minio.23544.com
|
||||||
|
port: 22106
|
||||||
|
username: marking
|
||||||
|
password: ${{ secrets.PWD_106 }}
|
||||||
|
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"
|
||||||
|
|
||||||
|
- name: 发送构建通知
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: actions/webhook@master
|
||||||
|
with:
|
||||||
|
urls: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fd8e4bfb-a906-4601-9894-e166b3ecedda
|
||||||
|
content_type: application/json
|
||||||
|
template: |
|
||||||
|
{
|
||||||
|
"msgtype": "markdown",
|
||||||
|
"markdown": {
|
||||||
|
"content": "${{ job.status == 'success' && '✅' || '❌' }}**${{ gitea.repository }}**
|
||||||
|
>**构建结果**: ${{ job.status }}
|
||||||
|
>**构建详情**: [点击查看](${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }})
|
||||||
|
>**代码分支**: ${{ gitea.ref_name }}
|
||||||
|
>**提交标识**: ${{ gitea.sha }}
|
||||||
|
>**提交发起**: ${{ gitea.actor}}
|
||||||
|
"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
marking-cut-service:
|
||||||
|
image: ${REGISTRY:-harbor.w.23544.com:8843}/marking/cut.service:${TAG:-latest}
|
||||||
|
hostname: marking
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Development}
|
||||||
|
# ports:
|
||||||
|
# - 9925:80
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
Loading…
Reference in New Issue