image: wagnerstephan/bitbucket-git-ftp:latest
clone:
  lfs: true
pipelines:
  custom:
    init-testing:
      - step:
          script:
            - git reset --hard
            - git ftp init -u "$FTP_USER" -p "$FTP_PASS" ftp://$FTP_HOST/testing
    deploy-testing:
      - step:
          script:
            - git reset --hard
            - git ftp push -u "$FTP_USER" -p "$FTP_PASS" ftp://$FTP_HOST/testing --all
    deploy-to-prod:
      - step:
          name: Deploy to prod
          script:
            - pipe: atlassian/ftp-deploy:0.3.6
              variables:
                USER: $FTP_USER
                PASSWORD: $FTP_PASS
                SERVER: $FTP_HOST/content/$BITBUCKET_TAG
                REMOTE_PATH: prod
                EXTRA_ARGS: "--exclude=.bitbucket/ --exclude=.git/ --exclude=bitbucket-pipelines.yml --exclude=.gitignore" # Ignore these
                DELETE_FLAG: 'true' # delete existing files on ftp-server
  branches:
    release/version_2.2:
      - step:
          name: deploy to test
          deployment: test
          script:
            - git reset --hard
            - git ftp push --force -u "$FTP_USER" -p "$FTP_PASS" ftp://$FTP_HOST/testing
    release/version_2.3:
      - step:
          name: deploy to test
          deployment: test
          script:
            - git reset --hard
            - git ftp push --force -u "$FTP_USER" -p "$FTP_PASS" ftp://$FTP_HOST/testing
