kind: pipeline
type: docker
name: default

steps:
  - name: build-image
    image: plugins/docker
    settings:
      repo: supanadit/todo
      username:
        from_secret: DOCKERUSER
      password:
        from_secret: DOCKERPASS

  - name: deploy
    image: appleboy/drone-ssh
    settings:
      host: supanadit.com
      username: root
      port: 22
      key:
        from_secret: SECRETKEY
      script:
        - cd /root/Docker/todo
        - docker-compose pull
        - docker-compose down
        - docker-compose up -d
        - docker-compose exec todo-app php artisan migrate
        - docker image prune

trigger:
  branch:
    - master