.drone.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ##############################
  2. # 测试环境部署
  3. ##############################
  4. kind: pipeline
  5. type: docker
  6. name: test-omega-admin
  7. volumes: # 声明数据卷
  8. - name: node_modules # 数据卷名称
  9. # Host Volume, 挂载到宿主机上的卷轴
  10. host:
  11. # 宿主机的绝对路径
  12. path: /home/ABServer/drone/cache/node_modules/test-omega-admin
  13. - name: targetDir
  14. host:
  15. path: /home/ABServer/drone/webroot/test-omega-admin
  16. - name: shellDir
  17. host:
  18. path: /home/ABServer/drone/config/shell
  19. - name: configDir
  20. host:
  21. path: /home/ABServer/drone/config/ossConfig
  22. - name: timezone
  23. host:
  24. path: /etc/localtime
  25. clone:
  26. disable: false
  27. steps:
  28. - name: build-project
  29. image: node:22-alpine
  30. pull: if-not-exists
  31. depends_on: [clone] # 依赖的步骤
  32. volumes: # 挂载数据卷
  33. - name: node_modules # 数据卷名称
  34. path: /drone/src/node_modules/ # 容器内目录 绝对路径
  35. - name: timezone
  36. path: /etc/localtime
  37. commands: # 执行命令
  38. - npm config set registry https://registry.npmmirror.com # 切换淘宝镜像
  39. - npm install -g pnpm@10.33.0
  40. - pnpm install --frozen-lockfile # 安装node_modules包
  41. - rm -rf dist
  42. - pnpm build:test # 执行编译
  43. - ls -al
  44. when:
  45. status:
  46. - success # 当前步骤成功时执行
  47. - name: deploy-project
  48. image: eclipse/alpine_jdk8
  49. user: root
  50. pull: if-not-exists
  51. depends_on: [build-project] # 依赖的步骤
  52. volumes: # 挂载数据卷
  53. - name: targetDir
  54. path: /deploy-target
  55. - name: shellDir
  56. path: /config/shell
  57. - name: configDir
  58. path: /root
  59. commands: # 执行命令
  60. - ls -al /drone/src/
  61. - cp -r /drone/src/dist/* /deploy-target/
  62. - chmod +x /config/shell/install.sh && /config/shell/install.sh
  63. - ossutil64 cp -rf /deploy-target/ oss://test-omega-admin
  64. trigger:
  65. branch:
  66. include:
  67. - test-omega-admin
  68. event:
  69. include:
  70. - push
  71. ##############################
  72. # 生产环境部署
  73. ##############################
  74. ---
  75. kind: pipeline
  76. type: docker
  77. name: release-omega-admin
  78. volumes: # 声明数据卷
  79. - name: node_modules # 数据卷名称
  80. # Host Volume, 挂载到宿主机上的卷轴
  81. host:
  82. # 宿主机的绝对路径
  83. path: /home/ABServer/drone/cache/node_modules/release-omega-admin
  84. - name: targetDir
  85. host:
  86. path: /home/ABServer/drone/webroot/release-omega-admin
  87. - name: shellDir
  88. host:
  89. path: /home/ABServer/drone/config/shell
  90. - name: configDir
  91. host:
  92. path: /home/ABServer/drone/config/ossConfig
  93. - name: timezone
  94. host:
  95. path: /etc/localtime
  96. clone:
  97. disable: false
  98. steps:
  99. - name: build-project
  100. image: node:22-alpine
  101. pull: if-not-exists
  102. depends_on: [clone] # 依赖的步骤
  103. volumes: # 挂载数据卷
  104. - name: node_modules # 数据卷名称
  105. path: /drone/src/node_modules/ # 容器内目录 绝对路径
  106. - name: timezone
  107. path: /etc/localtime
  108. commands: # 执行命令
  109. - npm config set registry https://registry.npmmirror.com # 切换淘宝镜像
  110. - npm install -g pnpm@10.33.0
  111. - pnpm install --frozen-lockfile # 安装node_modules包
  112. - rm -rf dist
  113. - pnpm build # 执行编译
  114. - ls -al
  115. when:
  116. status:
  117. - success # 当前步骤成功时执行
  118. - name: deploy-project
  119. image: eclipse/alpine_jdk8
  120. user: root
  121. pull: if-not-exists
  122. depends_on: [build-project] # 依赖的步骤
  123. volumes: # 挂载数据卷
  124. - name: targetDir
  125. path: /deploy-target
  126. - name: shellDir
  127. path: /config/shell
  128. - name: configDir
  129. path: /root
  130. commands: # 执行命令
  131. - ls -al /drone/src/
  132. - cp -r /drone/src/dist/* /deploy-target/
  133. - chmod +x /config/shell/install.sh && /config/shell/install.sh
  134. - ossutil64 cp -rf /deploy-target/ oss://omega-admin
  135. trigger:
  136. branch:
  137. include:
  138. - release-omega-admin
  139. event:
  140. include:
  141. - push