kind: pipeline
type: docker
name: api-extranetwork

trigger:
  branch:
    - main
  event:
    - push

steps:
  - name: deploy
    image: appleboy/drone-ssh
    settings:
      host:
        from_secret: DEPLOY_HOST
      username:
        from_secret: DEPLOY_USER
      key:
        from_secret: DEPLOY_SSH_KEY
      port: 22
      script:
        - set -e
        - cd /opt/docker/projects/api.extranetwork.com
        - git fetch origin main
        - git reset --hard origin/main
        - docker compose -f docker-compose.prod.yml up -d --build --remove-orphans
        - docker compose -f docker-compose.prod.yml exec -T app php artisan config:clear || true
        - docker compose -f docker-compose.prod.yml exec -T app php artisan cache:clear || true
        - docker compose -f docker-compose.prod.yml exec -T app php artisan route:clear || true
        - docker compose -f docker-compose.prod.yml exec -T app php artisan view:clear || true
        - echo "Deploy tamamlandı - $(date)"
