---
kind: pipeline
type: docker
name: build

steps:
  - name: notify-start
    image: appleboy/drone-discord
    settings:
      webhook_id:
        from_secret: discord_webhook_id
      webhook_token:
        from_secret: discord_webhook_secret
      message: 'Starting building **{{repo.name}}#{{build.number}}@{{build.commit}}** @ {{datetime build.started "02-Jan-2006 15:04:05 MST" "Asia/Yekaterinburg"}} (See {{build.link}} for logs).'

  - name: lint
    image: golangci/golangci-lint:latest
    environment:
      GOFLAGS: -mod=vendor
      CGO_ENABLED: 0
    commands:
      - golangci-lint run

  - name: test
    image: golang:1.13.1-alpine
    environment:
      GOFLAGS: -mod=vendor
      CGO_ENABLED: 0
    commands:
      - go test ./...

  - name: docker
    image: plugins/docker
    when:
      branch:
        master
    settings:
      username:
        from_secret: dockerhub_user
      password:
        from_secret: dockerhub_password
      repo: pztrn/fastpastebin
      auto_tag: true

  - name: notify-end
    when:
      status:
      - success
      - failure
    image: appleboy/drone-discord
    settings:
      webhook_id:
        from_secret: discord_webhook_id
      webhook_token:
        from_secret: discord_webhook_secret
      message: "
        {{#success build.status}}
          **{{repo.name}}#{{build.number}}@{{build.commit}}** built and pushed to hub.docker.com.
        {{ else }}
          **{{repo.name}}#{{build.number}}@{{build.commit}}** failed. See {{build.link}}.
        {{/success}}"