al-quran.reflectslight.io/lib/tasks/deploy/remote.rb
0x1eef 359cba7c39 add Tasks::Deploy::Remote
add a task for deploying the website to a remote - using rsync.
2022-11-02 13:54:21 -03:00

39 lines
696 B
Ruby

# frozen_string_literal: true
class Tasks::Deploy::Remote
attr_reader :hostname, :user, :path
def self.call
new.call
end
def initialize
@hostname = ENV["DEPLOY_HOSTNAME"]
@user = ENV["DEPLOY_USERNAME"]
@path = ENV["DEPLOY_PATH"]
@build_dir = File.join(Dir.getwd, "build", "al-quran", ".")
end
def call
rsync!
end
private
def rsync!
print "Wait...", "\n"
system(
"rsync",
"--delete",
"-rvah",
"--chmod=Du=rwx,Fu=rw",
@build_dir, "#{@user}@#{@hostname}:#{@path}"
)
if $?.success?
print "\n", Paint["OK", :green, :bold]
else
print Paint["ERROR", :red, :bold]
exit!
end
end
end