You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
5.1 KiB

  1. kind: pipeline
  2. name: default
  3. type: docker
  4. steps:
  5. # ============ RESTORE CACHE =============
  6. # - name: restore node_modules cache
  7. # image: appleboy/drone-sftp-cache
  8. # settings:
  9. # server:
  10. # from_secret: cache_server
  11. # port: 22
  12. # username:
  13. # from_secret: cache_server_user
  14. # key:
  15. # from_secret: cache_server_key
  16. # path: /var/cache/drone
  17. # restore: true
  18. # mount:
  19. # - node_modules
  20. # ============ BUILD STEPS ===============
  21. - name: build-prod
  22. image: glmdev/node-pnpm:latest
  23. commands:
  24. - pnpm i --silent
  25. - ./node_modules/.bin/ionic build --prod
  26. - ./node_modules/.bin/ngsw-config ./www/ ./ngsw-config.json /i
  27. - tar czf build.tar.gz www
  28. # =============== REBULD CACHE ==============
  29. # - name: rebuild node_modules cache
  30. # image: appleboy/drone-sftp-cache
  31. # settings:
  32. # server:
  33. # from_secret: cache_server
  34. # port: 22
  35. # username:
  36. # from_secret: cache_server_user
  37. # key:
  38. # from_secret: cache_server_key
  39. # path: /var/cache/drone
  40. # rebuild: true
  41. # mount:
  42. # - node_modules
  43. # =============== RELEASE ===============
  44. - name: release
  45. image: plugins/gitea-release
  46. settings:
  47. api_key:
  48. from_secret: gitea_api_key
  49. base_url: https://code.garrettmills.dev
  50. files: build.tar.gz
  51. title: ${DRONE_TAG}
  52. when:
  53. event: tag
  54. # =============== DEPLOY TO DEV SITE ===============
  55. - name: copy artifacts to staging site
  56. image: appleboy/drone-scp
  57. settings:
  58. host:
  59. from_secret: dev_site_host
  60. username:
  61. from_secret: dev_site_user
  62. key:
  63. from_secret: dev_site_key
  64. port: 22
  65. source: build.tar.gz
  66. target: /etc/glmdev/noded
  67. when:
  68. event: promote
  69. target: staging
  70. - name: deploy artifacts on staging site
  71. image: appleboy/drone-ssh
  72. settings:
  73. host:
  74. from_secret: dev_site_host
  75. username:
  76. from_secret: dev_site_user
  77. key:
  78. from_secret: dev_site_key
  79. port: 22
  80. script:
  81. - cd /etc/glmdev/noded
  82. - rm -rf www
  83. - tar xzf build.tar.gz
  84. - cd www
  85. - echo -n "$(uuidgen)" | sudo tee version.html
  86. when:
  87. event: promote
  88. target: staging
  89. # =============== DEPLOY TO PROD SITE ===============
  90. - name: copy artifacts to production site
  91. image: appleboy/drone-scp
  92. settings:
  93. host:
  94. from_secret: prod_site_host
  95. username:
  96. from_secret: prod_site_user
  97. key:
  98. from_secret: prod_site_key
  99. port: 22
  100. source: build.tar.gz
  101. target: /etc/glmdev/noded-prod
  102. when:
  103. event: promote
  104. target: production
  105. - name: deploy artifacts on production site
  106. image: appleboy/drone-ssh
  107. settings:
  108. host:
  109. from_secret: prod_site_host
  110. username:
  111. from_secret: prod_site_user
  112. key:
  113. from_secret: prod_site_key
  114. port: 22
  115. script:
  116. - cd /etc/glmdev/noded-prod
  117. - rm -rf www
  118. - tar xzf build.tar.gz
  119. - cd www
  120. - echo -n "$(uuidgen)" | sudo tee version.html
  121. when:
  122. event: promote
  123. target: production
  124. # =============== BUILD NOTIFICATIONS ===============
  125. - name: send build success notifications
  126. image: plugins/webhook
  127. settings:
  128. urls:
  129. from_secret: notify_webhook_url
  130. content_type: application/json
  131. template: |
  132. {
  133. "title": "Drone-CI [noded-frontend @ ${DRONE_BUILD_NUMBER}]",
  134. "message": "Build completed successfully. (Changes by ${DRONE_COMMIT_AUTHOR})",
  135. "priority": 4
  136. }
  137. when:
  138. status: success
  139. event:
  140. exclude:
  141. - promote
  142. - name: send build error notifications
  143. image: plugins/webhook
  144. settings:
  145. urls:
  146. from_secret: notify_webhook_url
  147. content_type: application/json
  148. template: |
  149. {
  150. "title": "Drone-CI [noded-frontend @ ${DRONE_BUILD_NUMBER}]",
  151. "message": "Build failed! (Changes by ${DRONE_COMMIT_AUTHOR})",
  152. "priority": 6
  153. }
  154. when:
  155. status: failure
  156. event:
  157. exclude:
  158. - promote
  159. # =============== DEPLOY NOTIFICATIONS ===============
  160. - name: send deploy success notifications
  161. image: plugins/webhook
  162. settings:
  163. urls:
  164. from_secret: notify_webhook_url
  165. content_type: application/json
  166. template: |
  167. {
  168. "title": "Drone-Deploy [noded-frontend @ ${DRONE_BUILD_NUMBER} to ${DRONE_DEPLOY_TO}]",
  169. "message": "Deployment completed successfully. (Changes by ${DRONE_COMMIT_AUTHOR})",
  170. "priority": 4
  171. }
  172. when:
  173. status: success
  174. event:
  175. - promote
  176. - name: send deploy error notifications
  177. image: plugins/webhook
  178. settings:
  179. urls:
  180. from_secret: notify_webhook_url
  181. content_type: application/json
  182. template: |
  183. {
  184. "title": "Drone-Deploy [noded-frontend @ ${DRONE_BUILD_NUMBER} to ${DRONE_DEPLOY_TO}]",
  185. "message": "Deployment failed! (Changes by ${DRONE_COMMIT_AUTHOR})",
  186. "priority": 6
  187. }
  188. when:
  189. status: failure
  190. event:
  191. - promote