kind: pipeline
type: docker
name: 自动部署

clone:
  disable: false # 禁用自带clone
  
workspace:
  path: /drone/src  

steps:
  - name: 镜像打包
    pull: if-not-exists
    image: plugins/docker
    settings:
      #dockerfile: Dockerfile
      repo: harbor.sxidc.com/fs/${DRONE_REPO_NAME//_/-}
      registry: harbor.sxidc.com
      tags: ${DRONE_COMMIT_BRANCH/master/latest}-${DRONE_BUILD_NUMBER}
      username:
        from_secret: harbor_username
      password:
        from_secret: harbor_password

  # 使用ssh访问主机制作镜像并运行
  - name: 集群部署
    pull: if-not-exists
    image: bh90210/dron8s:latest
    settings:
      repo_namespace: ywzx
      repo_name: ${DRONE_REPO_NAME//_/-}
      yaml: ./deployment-app.yaml
      image_addr: harbor.sxidc.com/fs/${DRONE_REPO_NAME//_/-}:${DRONE_COMMIT_BRANCH/master/latest}-${DRONE_BUILD_NUMBER}
      kubeconfig:
        from_secret: test_kubeconfig
      
      
trigger:
  branch:
    - main