workspace:
  base: /drone
  path: src

pipeline:
  tests:
    image: python:3.5

    environment:
      - PYTHONUSERBASE=/drone/src/cache/packages
      - POSTGRES_USER=mhackspace
      - USE_DOCKER=yes
      - DJANGO_SETTINGS_MODULE=config.settings.test
    commands:
      - cp -n env.example .env
      - mkdir -p ./cache/packages ./cache/pip
      - pip install --user --cache-dir ./cache/pip -r ./requirements/test.txt
      - python manage.py test mhackspace --verbosity 2

  publish-test:
    pull: True
    image: appleboy/drone-ssh
    host: maidstone-hackspace.org.uk
    user: ${SSH_USER}
    key: ${SSH_KEY}
    port: 22
    command_timeout: 480
    script:
      - cd /var/www/stage/maidstone-hackspace-website
      - git pull
      - docker-compose -fstage.yml down --remove-orphans 
      - docker-compose -fstage.yml build
      - docker-compose -fstage.yml up -d

  publish-live:
#    pull: True
    image: appleboy/drone-ssh
    user: {SSH_USER}
    key: {SSH_KEY}
    host: maidstone-hackspace.org.uk
    port: 22
    command_timeout: 480
    script:
      - echo 'to be added'
    when:
      event: [ tag ]

services:
  mailhog:
    image: mailhog/mailhog
