Deploy files that actually changed

I'm taking a stab at automatically deploying to an environment by reading some tutorials. I found an approach that I thought was really good but sometimes it's not accurate - some files don't get uploaded even though they were changed.

.gitlab-ci.yml

deploy:
  stage: deploy
  before_script:
    - apt-get update -qq && apt-get install -y -qq git
    - apt-get update -qq && apt-get install -y -qq lftp
    - curl --show-error --silent https://getcomposer.org/installer | php
    - php composer.phar install
  script:
    - lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$SSH_PASS $HOST; mirror -Rev . /public_html --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
  environment:
    name: production
    url: http://example.com
  only:
    - master

My biggest concern here is the --ignore-time flag which saves me a lot of time since it will only upload files that changed (barring time difference) but sometimes gives me headaches. There was a file where I only changed a single integer. I'm guessing in terms of file size, it remained the same but now the time the file was last modified changed but this factor is being ignored so this file was not deployed to the remote server. Removing the --ignore-time flag isn't the best idea as well because it re-uploads everything and takes a long time.

Questions

  • How do I fix this so that the list of files I'm deploying is accurate compared to the changes from a merge request?
  • Is lftp a good solution for what I'm trying to achieve? Is there a more standard approach to automatically deploying changes to a remote server?
Edited by Patrick Gregorio