add Tasks::Deploy::Remote
add a task for deploying the website to a remote - using rsync.
This commit is contained in:
parent
77790d70f9
commit
359cba7c39
7 changed files with 53 additions and 0 deletions
3
.env.sample
Normal file
3
.env.sample
Normal file
|
@ -0,0 +1,3 @@
|
|||
DEPLOY_HOSTNAME=
|
||||
DEPLOY_USERNAME=
|
||||
DEPLOY_PATH=
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ build/
|
|||
tmp/
|
||||
node_modules/
|
||||
*.log
|
||||
.env
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -8,3 +8,4 @@ gem "sass"
|
|||
gem "standardrb"
|
||||
gem "ryo.rb"
|
||||
gem "paint"
|
||||
gem "dotenv"
|
||||
|
|
|
@ -18,6 +18,7 @@ GEM
|
|||
ddmetrics (1.0.1)
|
||||
ddplugin (1.0.3)
|
||||
diff-lcs (1.5.0)
|
||||
dotenv (2.8.1)
|
||||
em-websocket (0.5.3)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0)
|
||||
|
@ -130,6 +131,7 @@ PLATFORMS
|
|||
x86_64-freebsd-13
|
||||
|
||||
DEPENDENCIES
|
||||
dotenv
|
||||
nanoc (~> 4.12)
|
||||
nanoc-live (~> 1.0)
|
||||
paint
|
||||
|
|
|
@ -15,6 +15,12 @@ namespace :deploy do
|
|||
task local: ["nanoc:compile"] do
|
||||
Deploy::Local.call
|
||||
end
|
||||
|
||||
task remote: ["nanoc:compile"] do
|
||||
require "dotenv"
|
||||
Dotenv.load
|
||||
Deploy::Remote.call
|
||||
end
|
||||
end
|
||||
|
||||
namespace :linter do
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
module Tasks::Deploy
|
||||
require_relative "deploy/local"
|
||||
require_relative "deploy/remote"
|
||||
end
|
||||
|
|
39
lib/tasks/deploy/remote.rb
Normal file
39
lib/tasks/deploy/remote.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
# 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
|
Loading…
Reference in a new issue