image: atlassian/default-image:latest

pipelines:
  default:
    - step:
        name: Build and Deploy
        script:
          - apt-get update && apt-get install -y curl
          - curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
          - apt-get install -y git-lfs
          - git lfs update --force 
          - git lfs install
          - git lfs update --force  # Fixes the pre-push hook issue
          - git lfs pull
          
          # Create the .htaccess file in the 'build' folder
          - echo 'RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^ index.html [L]

            RewriteCond %{HTTP_HOST} ^8rabbits\.com [NC]
            RewriteRule ^(.*)$ http://www.8rabbits.com/$1 [L,R=301]' > .htaccess
          
          # Deploy the files to the FTP server
          - pipe: atlassian/ftp-deploy:0.3.0
            variables:
              USER: $FTP_USERNAME
              PASSWORD: $FTP_PASSWORD
              SERVER: $FTP_SERVER
              REMOTE_PATH: /
              LOCAL_PATH: .
