kind: pipeline
name: like-sun

steps:
- name: build-test
  image: plugins/docker
  when:
    branch: deploy/like-test
    instance:
      exclude:
        - cicd.iyanzhi.com
  settings:
    dockerfile: deploy/test/Dockerfile
    registry: ccr.ccs.tencentyun.com
    username: 100009168942
    password: 3m4V#TMrUTSIebv1
    repo: ccr.ccs.tencentyun.com/gm-ai/like-sun
    tags:
      - ${DRONE_COMMIT}

- name: build-stage
  image: plugins/docker
  when:
    branch: deploy/like-stage
    instance:
      exclude:
        - cicd.gmapp.env
  settings:
    dockerfile: deploy/stage/Dockerfile
    registry: ccr.ccs.tencentyun.com
    username: 100009168942
    password: 3m4V#TMrUTSIebv1
    repo: ccr.ccs.tencentyun.com/gm-ai/like-sun
    tags:
      - ${DRONE_COMMIT}

- name: build-prod
  image: plugins/docker
  when:
    branch: deploy/like-prod
    instance:
      exclude:
        - cicd.gmapp.env
  settings:
    dockerfile: deploy/prod/Dockerfile
    registry: ccr.ccs.tencentyun.com
    dockerfile: deploy/prod/Dockerfile
    username: 100009168942
    password: 3m4V#TMrUTSIebv1
    repo: ccr.ccs.tencentyun.com/gm-ai/like-sun
    tags:
      - ${DRONE_COMMIT}

- name: deploy-app
  image: ccr.ccs.tencentyun.com/gm-ai/drone-kube:pre
  environment:
    repo: alpha/sun
  when:
    branch:
      - deploy/like-prod
      - deploy/like-stage
    instance:
      exclude:
        - cicd.gmapp.env
  settings:
    namespace: ${DRONE_BRANCH}
    template: deploy.yaml
    tag: ${DRONE_COMMIT}

- name: deploy-celery
  image: ccr.ccs.tencentyun.com/gm-ai/drone-kube:pre
  environment:
    repo: alpha/sun
  when:
    branch:
      - deploy/like-prod
      - deploy/like-stage
    instance:
      exclude:
        - cicd.gmapp.env
  settings:
    namespace: ${DRONE_BRANCH}
    template: deploy.celery.yaml
    tag: ${DRONE_COMMIT}

- name: deploy-app-test
  image: ccr.ccs.tencentyun.com/gm-ai/drone-kube:test
  when:
    branch:
      - deploy/like-test
    instance:
      exclude:
        - cicd.iyanzhi.com
  environment:
    repo: alpha/sun
  settings:
    namespace: ${DRONE_BRANCH}
    template: deploy.yaml
    tag: ${DRONE_COMMIT}

- name: deploy-celery-test
  image: ccr.ccs.tencentyun.com/gm-ai/drone-kube:test
  when:
    branch:
      - deploy/like-test
    instance:
      exclude:
        - cicd.iyanzhi.com
  environment:
    repo: alpha/sun
  settings:
    namespace: ${DRONE_BRANCH}
    template: deploy.celery.yaml
    tag: ${DRONE_COMMIT}

trigger:
  branch:
  - deploy/*

image_pull_secrets:
  - dockerconfig
