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}} " } }