steps:
  - name: HTML syntax check
    image: debian:12
    # Debian has tidy 5.6.0, which complains about the "loading" tag in img.
    # We need a more recent version for now.
    commands:
      - DEBIAN_FRONTEND=noninteractive apt update -qq
      - DEBIAN_FRONTEND=noninteractive apt install -qq -y wget
      - wget -q https://github.com/htacg/tidy-html5/releases/download/5.8.0/tidy-5.8.0-Linux-64bit.deb
      - echo "59e594312207234f5a17455683c13c6bc47a89cb7bf994d493acfffb591d9830 tidy-5.8.0-Linux-64bit.deb" | sha256sum -c
      - DEBIAN_FRONTEND=noninteractive apt install -qq -y ./tidy-5.8.0-Linux-64bit.deb
      - tidy -q -e static/index.html

  - name: upload (preprod)
    when:
      event: [push, pull_request]
      branch: preprod
    image: plugins/s3
    settings:
      bucket: preprod-site
      endpoint: https://garage.deuxfleurs.fr
      region: garage
      access_key:
        from_secret: aws_access_key_id
      secret_key:
        from_secret: aws_secret_access_key
      source: static/**/*
      target: /
      strip_prefix: static/
      path_style: true

  - name: upload (prod)
    when:
      - event: push
        branch: main
    image: plugins/s3
    settings:
      bucket: deuxfleurs.fr
      endpoint: https://garage.deuxfleurs.fr
      region: garage
      access_key:
        from_secret: aws_access_key_id
      secret_key:
        from_secret: aws_secret_access_key
      source: static/**/*
      target: /
      strip_prefix: static/
      path_style: true
