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.

58 lines
1.3 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 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. image: alpine:3.10
  21. when:
  22. condition: ${DRONE_DEPLOY_ENABLED}
  23. target: [ "test","pre" ]
  24. environment:
  25. ENVIRONMENT: "hi"
  26. - name: tar-prod-push
  27. privileged: true
  28. image: registry.cn-hangzhou.aliyuncs.com/hvp/dpr:75
  29. settings:
  30. tar: ops-api-${DRONE_BUILD_NUMBER}.tar
  31. commands:
  32. - suffix=$(echo "${IMAGE}" | awk -F '/' '{split($NF, a, ":"); print a[2]}')
  33. - echo ${suffix}
  34. - docker images | grep "ops-api" | grep ${suffix} | awk '{print $3}' | xargs docker rmi
  35. when:
  36. target: [ "hi","prod" ]
  37. - name: deployment-replace-prod
  38. image: repository.241210.com/repository/base/kubectl:4
  39. commands:
  40. - cd web/
  41. - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml
  42. when:
  43. target: [ "exp","prod" ]
  44. - name: deploy-prod
  45. image: repository.241210.com/repository/base/kubectl:4
  46. commands:
  47. - cd web/
  48. - kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml
  49. when:
  50. target: [ "exp","prod" ]