kind: pipeline
name: mkdocs build and deploy
type: docker
platform:
  os: linux
  arch: amd64
trigger:
  branch:
    - prod

steps:

# BUILD
- name: build
  image: squidfunk/mkdocs-material:9
  pull: always
  volumes:
  - name: site
    path: /drone/src/docs
  commands:
    - pip install -r requirements.txt && mkdocs build

# PUSH FILES TO SERVER
- name: deploy files on server
  image: drillster/drone-rsync
  settings:
    hosts: ["92.243.16.7"]
    target: /var/www/html/mkdoc/site
    source: public/*
    user:
      from_secret: RSYNC_USER
    key:
      from_secret: RSYNC_HOST_KEY

# TO CONFIG AND TEST - SEND MAIL NOTIF   
- name: notify
  image: drillster/drone-email
  settings:
    from.address: contact@legaragenumerique.fr
    host: mail.gandi.net
    port: 465
#    skip_verify: true
    debug: true
    username: contact@legaragenumerique.fr
    password:
      from_secret: MAIL_PASSWORD
    recipients: [ contact@legaragenumerique.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://www.legaragenumerique.fr/wp-content/uploads/2019/10/logo-web-garage_numerique.png'/>
  when:
    status: [ success, failure ]
    