stages:
  - deploy

deploy_to_caprover:
  stage: deploy
  image: alpine:3.19
  only:
    - main
  script:
    - apk add --no-cache curl git tar
    - tar -czf /tmp/deploy.tar.gz --exclude='.git' --exclude='vendor' --exclude='node_modules' --exclude='storage/logs' --exclude='storage/sessions' .
    - |
      curl -X POST "$CAPROVER_URL/api/v2/user/apps/appData/$CAPROVER_APP" \
        -H "x-captain-app-token: $CAPROVER_APP_TOKEN" \
        -H "Content-Type: application/tar+gzip" \
        --data-binary @/tmp/deploy.tar.gz \
        --fail --silent --show-error
  environment:
    name: demo
    url: $DEMO_URL
