.drone.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. kind: pipeline
  2. type: docker
  3. name: miniprogram-manager-prod
  4. volumes: # 声明数据卷
  5. - name: targetDir
  6. host:
  7. path: /miniprogram-manager
  8. clone:
  9. disable: false # 启用代码拉取
  10. steps:
  11. - name: build-project
  12. image: mcr.microsoft.com/dotnet/core/sdk:3.0-alpine
  13. pull: if-not-exists
  14. depends_on: [clone] # 依赖的步骤
  15. volumes: # 挂载数据卷
  16. - name: targetDir
  17. path: /drone/src/dist/
  18. commands: # 执行命令
  19. - echo '' > ~/.nuget/NuGet/NuGet.Config
  20. - echo '<?xml version="1.0" encoding="utf-8"?><configuration><packageSources><add key="nuget.org" value="https://nuget.cdn.azure.cn/v3/index.json" protocolVersion="3" /></packageSources></configuration>' > ~/.nuget/NuGet/NuGet.Config
  21. - rm -rf /drone/src/dist/*
  22. - dotnet publish -c release -o ./publish
  23. - cp -r ./publish/* /drone/src/dist # 复制文件
  24. when:
  25. status:
  26. - success # 当前步骤成功时执行
  27. - name: scp-project
  28. image: appleboy/drone-scp
  29. pull: if-not-exists
  30. depends_on: [build-project] # 依赖的步骤
  31. volumes: # 挂载数据卷
  32. - name: targetDir # 数据卷名称
  33. path: /miniprogram-manager # 容器内目录 绝对路径
  34. settings:
  35. host:
  36. from_secret: miniprogram-manager-host-a
  37. username:
  38. from_secret: username
  39. password:
  40. from_secret: userpwd
  41. port: 22
  42. command_timeout: 2m
  43. target: /home/ABServer/deploy-ready/
  44. source:
  45. - echo ====开始拷贝=======
  46. - /miniprogram-manager/*
  47. - echo ====结束拷贝=======
  48. when:
  49. status:
  50. - success # 当前步骤成功时执行
  51. - name: deploy-project
  52. image: appleboy/drone-ssh
  53. pull: if-not-exists
  54. depends_on: [scp-project] # 依赖的步骤
  55. settings:
  56. host:
  57. from_secret: miniprogram-manager-host-a
  58. username:
  59. from_secret: username
  60. password:
  61. from_secret: userpwd
  62. port: 22
  63. command_timeout: 2m
  64. script:
  65. - echo ====开始部署=======
  66. - cd /home/ABServer/
  67. - cp -r /home/ABServer/deploy-ready/miniprogram-manager /home/ABServer/webroot/
  68. - docker restart miniprogram-manager
  69. # - docker restart nodeServer1
  70. - echo ====部署成功=======
  71. - name: scp-project-b
  72. image: appleboy/drone-scp
  73. pull: if-not-exists
  74. depends_on: [build-project] # 依赖的步骤
  75. volumes: # 挂载数据卷
  76. - name: targetDir # 数据卷名称
  77. path: /miniprogram-manager # 容器内目录 绝对路径
  78. settings:
  79. host:
  80. from_secret: miniprogram-manager-host-b
  81. username:
  82. from_secret: username
  83. password:
  84. from_secret: userpwd
  85. port: 22
  86. command_timeout: 2m
  87. target: /home/ABServer/deploy-ready/
  88. source:
  89. - echo ====开始拷贝=======
  90. - /miniprogram-manager/*
  91. - echo ====结束拷贝=======
  92. when:
  93. status:
  94. - success # 当前步骤成功时执行
  95. - name: deploy-project-b
  96. image: appleboy/drone-ssh
  97. pull: if-not-exists
  98. depends_on: [scp-project] # 依赖的步骤
  99. settings:
  100. host:
  101. from_secret: miniprogram-manager-host-b
  102. username:
  103. from_secret: username
  104. password:
  105. from_secret: userpwd
  106. port: 22
  107. command_timeout: 2m
  108. script:
  109. - echo ====开始部署=======
  110. - cd /home/ABServer/
  111. - cp -r /home/ABServer/deploy-ready/miniprogram-manager /home/ABServer/webroot/
  112. - docker restart miniprogram-manager
  113. # - docker restart nodeServer1
  114. - echo ====部署成功=======
  115. trigger:
  116. branch:
  117. - release-miniprogram-manager
  118. event:
  119. - push
  120. #排除合并请求
  121. exclude:
  122. - ref: refs/pull/*