added FTP deployment
This commit is contained in:
parent
2b33d3d409
commit
817ac132c0
4 changed files with 68 additions and 3 deletions
16
README.md
16
README.md
|
@ -95,6 +95,22 @@ To use a particular branch, add:
|
|||
Default is `gh-pages`. Run `git branch -a` to see a list of possible
|
||||
branches.
|
||||
|
||||
### Step 4c - FTP setup
|
||||
|
||||
#### These settings are required.
|
||||
|
||||
Edit `config.rb`, and add:
|
||||
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :ftp
|
||||
deploy.host = "ftp.example.com"
|
||||
deploy.user = "tvaughan"
|
||||
deploy.password = "secret"
|
||||
deploy.path = "/srv/www/site"
|
||||
end
|
||||
|
||||
Adjust these values accordingly.
|
||||
|
||||
### Step 5
|
||||
|
||||
middleman build [--clean]
|
||||
|
|
|
@ -140,6 +140,54 @@ EOF
|
|||
orig.remote(remote).fetch
|
||||
end
|
||||
|
||||
def deploy_ftp
|
||||
require 'net/ftp'
|
||||
require 'ptools'
|
||||
|
||||
host = self.deploy_options.host
|
||||
user = self.deploy_options.user
|
||||
pass = self.deploy_options.password
|
||||
path = self.deploy_options.path
|
||||
|
||||
puts "## Deploying via ftp to #{user}@#{host}:#{path}"
|
||||
|
||||
ftp = Net::FTP.new(host)
|
||||
ftp.login(user, pass)
|
||||
ftp.chdir(path)
|
||||
ftp.passive = true
|
||||
|
||||
Dir.chdir('build/') do
|
||||
Dir['**/*'].each do |f|
|
||||
if File.directory?(f)
|
||||
begin
|
||||
ftp.mkdir(f)
|
||||
rescue
|
||||
puts "Folder '#{f}' exists. skipping..."
|
||||
end
|
||||
else
|
||||
begin
|
||||
if File.binary?(f)
|
||||
ftp.putbinaryfile(f, f)
|
||||
else
|
||||
ftp.puttextfile(f, f)
|
||||
end
|
||||
rescue Exception => e
|
||||
reply = e.message
|
||||
err_code = reply[0,3].to_i
|
||||
if err_code == 550
|
||||
if File.binary?(f)
|
||||
ftp.putbinaryfile(f, f)
|
||||
else
|
||||
ftp.puttextfile(f, f)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ftp.close
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Alias "d" to "deploy"
|
||||
|
|
|
@ -5,7 +5,7 @@ require "middleman-core"
|
|||
module Middleman
|
||||
module Deploy
|
||||
|
||||
class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :path, :clean, :remote, :branch, :after_build); end
|
||||
class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :after_build); end
|
||||
|
||||
class << self
|
||||
|
||||
|
|
|
@ -16,10 +16,11 @@ Gem::Specification.new do |s|
|
|||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||
s.require_paths = ["lib"]
|
||||
|
||||
|
||||
# The version of middleman-core your extension depends on
|
||||
s.add_runtime_dependency("middleman-core", [">= 3.0.0"])
|
||||
|
||||
|
||||
# Additional dependencies
|
||||
s.add_runtime_dependency("git", "~> 1.2.0")
|
||||
s.add_runtime_dependency("ptools")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue