when:
  - event: push
    branch: main

depends_on:
  - ci

steps:
  build:
    image: oven/bun:debian
    environment:
      FTP_HOST:
        from_secret: FTP_HOST
      FTP_USERNAME:
        from_secret: FTP_USERNAME
      FTP_PASSWORD:
        from_secret: FTP_PASSWORD
    commands:
      - apt-get update && apt-get install -y curl make
      - curl -fsSL https://d2lang.com/install.sh | sh -s --
      - bun install
      - bun run build
      # Deploy using Sam Kirkland's script via Bun (ultra fast)
      # We use 'bunx' to run the package without permanently installing it
      - |
        bunx @samkirkland/ftp-deploy \
          --server "$FTP_HOST" \
          --username "$FTP_USERNAME" \
          --password "$FTP_PASSWORD" \
          --local-dir "dist/" \
          --server-dir "/" \
          --log-level "standard"
