name: Deploy Site

on: [push]

jobs:
  deploy:
    runs-on: docker
    steps:
      - uses: actions/checkout@v4

      - name: Build Docker Image
        run: docker build -t docloud.es:latest .

      - name: Deploy to Production
        run: |
          docker stop docloud.es || true
          docker rm docloud.es || true
          docker run -d \
            --name docloud.es \
            --network traefik_network \
            --restart unless-stopped \
            --label "traefik.enable=true" \
            --label "traefik.http.routers.docloudprod.rule=Host(\`docloud.es\`)" \
            --label "traefik.http.routers.docloudprod.tls=true" \
            --label "traefik.http.routers.docloudprod.tls.certresolver=myresolver" \
            --label "traefik.http.middlewares.docloudprod-compress.compress=true" \
            --label "traefik.http.routers.docloudprod.middlewares=docloudprod-compress" \
            docloud.es:latest
