Skip to content

Instantly share code, notes, and snippets.

@syahrasi
Forked from stravid/task.thor
Created January 23, 2014 00:25
Show Gist options
  • Save syahrasi/8570440 to your computer and use it in GitHub Desktop.
Save syahrasi/8570440 to your computer and use it in GitHub Desktop.
desc "deploy", "deploys the site via LFTP to the location specified in the environment"
def deploy
load_ftp_configuration
start_timestamp = Time.now.to_i
if system("lftp -e 'mirror -R -v #{ENV['PUBLIC_DIRECTORY']} #{ENV['FTP_TARGET_DIRECTORY']}; bye' -u #{ENV['FTP_USER']},#{ENV['FTP_PASSWORD']} #{ENV['FTP_SERVER']}")
puts "Deploy finished. (Duration: #{Time.now.to_i - start_timestamp} seconds)"
else
puts 'Deploy aborted, something went wrong.'
end
end
private
def load_ftp_configuration
configuration_file = "ftp_configuration.yml"
if File.exists? configuration_file
configuration_hash = YAML.load_file configuration_file
configuration_hash.each do |key, value|
ENV[key.upcase] = value
end
else
throw 'Missing `ftp_configuration.yml` to specify ftp configuration variables.'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment