.drone.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. kind: pipeline
  2. type: docker
  3. name: kxs-activityserver-test
  4. volumes: # 声明数据卷
  5. - name: targetDir
  6. host:
  7. path: /kxs_activityserver_com
  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. - dotnet publish -c release -o ./publish
  20. - ls ./publish
  21. - cp -r ./publish/* /drone/src/dist # 复制文件
  22. - ls /drone/src/dist
  23. when:
  24. status:
  25. - success # 当前步骤成功时执行
  26. - name: scp-project
  27. image: appleboy/drone-scp
  28. pull: if-not-exists
  29. depends_on: [build-project] # 依赖的步骤
  30. volumes: # 挂载数据卷
  31. - name: targetDir # 数据卷名称
  32. path: /kxs_activityserver_com # 容器内目录 绝对路径
  33. settings:
  34. host:
  35. from_secret: host
  36. username:
  37. from_secret: username
  38. password:
  39. from_secret: userpwd
  40. port: 22
  41. command_timeout: 2m
  42. target: /home/ABServer/deploy-ready/
  43. source:
  44. - echo ====开始拷贝=======
  45. - /kxs_activityserver_com/*
  46. - echo ====结束拷贝=======
  47. when:
  48. status:
  49. - success # 当前步骤成功时执行
  50. - name: deploy-project
  51. image: appleboy/drone-ssh
  52. pull: if-not-exists
  53. depends_on: [scp-project] # 依赖的步骤
  54. settings:
  55. host:
  56. from_secret: host
  57. username:
  58. from_secret: username
  59. password:
  60. from_secret: userpwd
  61. port: 22
  62. command_timeout: 2m
  63. script:
  64. - echo ====开始部署=======
  65. - cd /home/ABServer/
  66. - cp -r /home/ABServer/deploy-ready/kxs_activityserver_com /home/ABServer/webroot/
  67. # - docker stop kxs_activityserver_com && docker rm kxs_activityserver_com && docker-compose up -d kxs_activityserver_com
  68. - docker restart kxs_activityserver_com
  69. - echo ====部署成功=======
  70. trigger:
  71. branch:
  72. include:
  73. - test-activityserver
  74. event:
  75. include:
  76. - pull_request
  77. - push