kind: pipeline
type: kubernetes
name: default

trigger:
  event:
    - push

# STAGING!!!!!!!!!!!!!
steps:
- name: docker
  image: plugins/docker
  settings:
    username: 
      from_secret: docker_username
    password:
      from_secret: docker_password
    repo: dutchellie/proper-website-2
    build_args:
      - APIURL=https://api.quenten.nl/api/testing
    tags: 
      - dev
      - ${DRONE_COMMIT_SHA:0:8}
- name: deploy-staging
  image: pelotech/drone-helm3
  settings:
    mode: upgrade
    chart: .drone/helm/chart
    namespace: drone-staging
    release: newsite-staging
    skip_tls_verify: true
    values_files:
#      - .drone/helm/values.yaml
      - .drone/helm/staging-val.yaml
    values:
      - "image=dutchellie/proper-website-2:${DRONE_COMMIT_SHA:0:8}"
    kube_api_server:
      from_secret: staging_api_server
    kube_token:
      from_secret: staging_kube_token
    kube_certificate:
      from_secret: staging_kube_certificate
    kube_service_account: drone-deploy
    dry_run: false

---

kind: pipeline
type: kubernetes
name: deploy-prod

trigger:
  event:
    - promote
  target:
    - production

steps:
- name: docker
  image: plugins/docker
  settings:
    username: 
      from_secret: docker_username
    password: 
      from_secret: docker_password
    repo: dutchellie/proper-website-2
    build_args:
      - APIURL=https://api.quenten.nl/api
    tags: 
      - latest
      - ${DRONE_COMMIT_SHA:0:8}
- name: deploy-production
  image: pelotech/drone-helm3
  settings:
    mode: upgrade
    chart: .drone/helm/chart
    namespace: drone-production
    release: newsite-production
    skip_tls_verify: true
    values_files:
#      - .drone/helm/values.yaml
      - .drone/helm/prod-val.yaml
    values:
      - "image=dutchellie/proper-website-2:${DRONE_COMMIT_SHA:0:8}"
    kube_api_server:
      from_secret: prod_api_server
    kube_token:
      from_secret: prod_kube_token
    kube_certificate:
      from_secret: prod_kube_certificate
    kube_service_account: drone-deploy
    dry_run: false
