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.

59 lines
1.4 KiB

3 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. ---
  2. kind: pipeline
  3. type: docker
  4. name: default
  5. volumes:
  6. - name: gopath
  7. host:
  8. path: /usr/local/path/gopath
  9. steps:
  10. - name: golang-build
  11. image: golang:1.17-alpine3.15
  12. volumes:
  13. - name: gopath
  14. path: /go
  15. commands:
  16. - echo "hello world"
  17. when:
  18. target: [ "test","pre" ]
  19. - name: prod-deploy
  20. when:
  21. condition: ${DRONE_DEPLOY_ENABLED}
  22. target: [ "test","pre" ]
  23. environment:
  24. ENVIRONMENT: hi
  25. - name: tar-prod-push
  26. privileged: true
  27. image: registry.cn-hangzhou.aliyuncs.com/hvp/dpr:75
  28. settings:
  29. tar: ops-api-${DRONE_BUILD_NUMBER}.tar
  30. commands:
  31. - docker pull ${IMAGE}
  32. - docker save ${IMAGE} >ops-api-${DRONE_BUILD_NUMBER}.tar
  33. - dpr
  34. - suffix=$(echo "$IMAGE" | awk -F '/' '{split($NF, a, ":"); print a[2]}')
  35. - docker images | grep "ops-api" | grep ${suffix} | awk '{print $3}' | xargs docker rmi
  36. when:
  37. target: [ "hi","prod" ]
  38. - name: deployment-replace-prod
  39. image: repository.241210.com/repository/base/kubectl:4
  40. commands:
  41. - cd web/
  42. - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml
  43. when:
  44. target: [ "exp","prod" ]
  45. - name: deploy-prod
  46. image: repository.241210.com/repository/base/kubectl:4
  47. commands:
  48. - cd web/
  49. - kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml
  50. when:
  51. target: [ "exp","prod" ]