workspace:
  base: /go
  path: src/github.com/ipedrazas/drone-helm

pipeline:
  test:
    image: golang:1.8
    commands:
      - go get
      - go test -cover -coverprofile=coverage.out

  compile:
    image: golang:1.8
    commands:
      - export PATH=$PATH:/go/bin
      - go build -ldflags "-s -w -X main.build=$DRONE_BUILD_NUMBER" -a -tags netgo


  build_docker_image:
    image: docker:17.05-dind
    environment:
      - DOCKER_HOST=tcp://127.0.0.1:2375
      - TAG=$DRONE_BRANCH-$DRONE_COMMIT_SHA:0:7
    commands:
      - docker login -u="$QUAY_USERNAME" -p="$QUAY_PASSWORD" quay.io
      - docker build -t image .
      - docker tag image quay.io/ipedrazas/drone-helm:$TAG
      - docker push quay.io/ipedrazas/drone-helm
    secrets: ["quay_username", "quay_password"]
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  
  build_docker_latest:
    image: docker:17.05-dind
    environment:
      - DOCKER_HOST=tcp://127.0.0.1:2375
      - TAG=$DRONE_BRANCH-$DRONE_COMMIT_SHA:0:7
    commands:
      - docker login -u="$QUAY_USERNAME" -p="$QUAY_PASSWORD" quay.io
      - docker build -t image .
      - docker tag image quay.io/ipedrazas/drone-helm:latest
      - docker tag image quay.io/ipedrazas/drone-helm:$TAG
      - docker push quay.io/ipedrazas/drone-helm
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    when:
     event: [push]
     branch: [master]

  slack:
    image: plugins/slack
    channel: deploys
    username: drone
    template: >
      {{ build.author }} finished building  *<http://drone.sohohousedigital.com/SohoHouse/{{ repo.name }}/{{ build.number }}|{{ build.branch }} ({{ build.number }})>* of {{ repo.name }}  with a {{ build.status }} status
    secrets: ["slack_webhook"]

plugin:
  name: drone-helm
  desc: Execute helm to
  type: deploy
  image: quay.io/ipedrazas/drone-helm
  labels:
    - deploy
    - kubernetes
    - helm
