  version: 2
  name: 自动部署
  description: ""
  global:
    concurrent: 1
  trigger:
    webhook: gitlink@1.0.0
    event:
      - ref: push
        ruleset-operator: AND
  workflow:
    - ref: start
      name: 开始
      task: start
    - ref: git_clone_0
      name: git clone
      task: git_clone@1.2.9
      input:
        username: ((gitlink_help_center.ylly_git_user))
        password: ((gitlink_help_center.ylly_git_pass))
        remote_url: '"https://gitlink.org.cn/ylly/gitlink_help_center.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: ((gitlink_help_center.acr_username))
        docker_password: ((gitlink_help_center.acr_password))
        image_name: '"crpi-3vrif0lgpchh92c8.cn-hangzhou.personal.cr.aliyuncs.com/ylly/gitlink_help_center"'
        image_tag: '"latest"'
        registry_address: '"crpi-3vrif0lgpchh92c8.cn-hangzhou.personal.cr.aliyuncs.com"'
        docker_file: '"Dockerfile"'
        docker_build_path: '"."'
        workspace: git_clone_0.git_path
        image_push: true
        build_args: '""'
      needs:
        - git_clone_0
    - ref: ssh_cmd_0
      name: ssh执行命令
      task: ssh_cmd@1.1.1
      input:
        ssh_pass: ((gitlink_help_center.ecs_ssh_key))
        ssh_ip: '"223.6.254.149"'
        ssh_port: '"22"'
        ssh_user: '"root"'
        ssh_cmd: '"docker stop ghc_ylly;docker rm ghc_ylly;docker pull crpi-3vrif0lgpchh92c8.cn-hangzhou.personal.cr.aliyuncs.com/ylly/gitlink_help_center:latest;docker run -d -p 3000:3000 --name ghc_ylly crpi-3vrif0lgpchh92c8.cn-hangzhou.personal.cr.aliyuncs.com/ylly/gitlink_help_center:latest"'
      needs:
        - docker_image_build_0
    - ref: end
      name: 结束
      task: end
      needs:
        - ssh_cmd_0
