kind: pipeline
name: hugo
type: docker

platform:
  os: linux
  arch: arm64

trigger:
  branch:
    - main

steps:

- name: build docker image and push to registry
  image: plugins/docker
  volumes:
  - name: dockersock
    path: "/var/run/docker.sock"
  settings:
    debug: true
    username:
      from_secret: REGISTRY_USER
    password:
      from_secret: REGISTRY_PASSWORD
    registry: "dockerregistry.gregandev.fr"
    insecure: true
    privileged: true
    repo: "dockerregistry.gregandev.fr/re-site"
    dockerfile: ./Dockerfile

- name: notify
  image: greglebreton/drone-email:arm64
  settings:
    from.address: contact@gregandev.fr
    host: mail.gregandev.fr
    port: 587
    debug: true
    username: contact@gregandev.fr
    password:
      from_secret: MAIL_PASSWORD
    recipients: [ greg@gregandev.fr ]
    subject: >
      [{{ build.status }}]
      {{ repo.owner }}/{{ repo.name }}            
    body: >
      📝 {{repo.name}} / {{commit.branch}} - {{commit.message}} <br />
      {{#success build.status}}
        ✅ succeeded  for 👷‍♂️ build {{build.number}}
      {{else}}
        🛑 failed for 👷‍♂️ build {{build.number}}
      {{/success}}  
      <br /><img src='https://git.gregandev.fr/assets/img/logo.svg'/>      
  when:
    status: [ success, failure ]