version: 2
name: api
description: ""
global:
  concurrent: 1
  param:
    - ref: deploy_path
      name: deploy_path
      value: '"pcm-coordinator-api.yaml"'
      required: false
      type: STRING
      hidden: false
    - ref: secret_name
      name: ""
      value: '"jcce-aliyuncs"'
      required: false
      type: STRING
      hidden: false
    - ref: project_name
      name: ""
      value: '"pcm-coordinator-api"'
      required: false
      type: STRING
      hidden: false
trigger:
  webhook: gitlink@1.0.0
  event:
    - ref: create_tag
      ruleset:
        - param-ref: tag
          operator: EQ
          value: '""'
      ruleset-operator: AND
workflow:
  - ref: start
    name: 开始
    task: start
  - ref: git_clone_0
    name: git clone
    task: git_clone@1.2.6
    input:
      remote_url: '"https://gitlink.org.cn/JointCloud/pcm-coordinator.git"'
      ref: '"refs/heads/master"'
      commit_id: '""'
      depth: 1
    needs:
      - start
  - ref: docker_image_build_0
    name: docker镜像构建
    task: docker_image_build@1.6.0
    input:
      docker_username: ((dev.docker_user))
      docker_password: ((dev.docker_password))
      image_name: '"registry.cn-hangzhou.aliyuncs.com/jcce/pcm-coordinator-api"'
      image_tag: git_clone_0.commit_time
      registry_address: '"registry.cn-hangzhou.aliyuncs.com"'
      docker_file: git_clone_0.git_path + '/api/Dockerfile'
      docker_build_path: git_clone_0.git_path
      workspace: git_clone_0.git_path
      image_clean: true
      image_push: true
      build_args: '""'
    needs:
      - shell_0
  - ref: end
    name: 结束
    task: end
    needs:
      - kubectl_deploy_0
  - ref: kubectl_deploy_0
    name: kubectl部署资源
    task: kubectl_deploy@1.1.0
    input:
      command: '"apply"'
      resource_file_path: git_clone_0.git_path + '/api'
      certificate_authority_data: ((dev.k8s_cad))
      server: '"https://119.45.100.73:6443"'
      client_certificate_data: ((dev.k8s_ccd))
      client_key_data: ((dev.k8s_ckd))
      hosts: '""'
    needs:
      - docker_image_build_0
  - ref: shell_0
    name: shell
    image: docker.jianmuhub.com/library/debian:buster-slim
    env:
      IMAGE_NAME: '"registry.cn-hangzhou.aliyuncs.com/jcce/pcm-coordinator-api"'
      IMAGE_TAG: git_clone_0.commit_time
      SECRET_NAME: global.secret_name
      PROJECT_NAME: global.project_name
      PROJECT_PATH: git_clone_0.git_path
    script:
      - cd ${PROJECT_PATH}/api
      - sed -i "s#image_name#${IMAGE_NAME}:${IMAGE_TAG}#" ${PROJECT_NAME}.yaml
      - sed -i "s#secret_name#${SECRET_NAME}#" ${PROJECT_NAME}.yaml
      - cat ${PROJECT_NAME}.yaml
    needs:
      - git_clone_0

