stages:
  - install
  - deploy

install:
  stage: install
  image: composer:2.7
  cache:
    key: composer
    paths:
      - vendor/
      - ~/.composer/cache
  script:
    - composer install --ignore-platform-req=ext-gd --no-dev --no-interaction --prefer-dist --optimize-autoloader
  artifacts:
    paths:
      - vendor/

deploy:
  stage: deploy
  image: alpine:3.20
  before_script:
    - apk add --no-cache lftp
  only:
    - main
  script:
    - lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD $HOST;

      mirror --reverse --delete --verbose --ignore-time --parallel=10 assets assets;
      mirror --reverse --delete --verbose --ignore-time --parallel=10 kirby kirby;
      mirror --reverse --delete --verbose --ignore-time --parallel=10 -x accounts/ -x cache/ -x sessions/ site site;
      mirror --reverse --delete --verbose --ignore-time --parallel=10 -x .git/ -x .gitlab-ci.yml vendor vendor;

      quit"
