Skip to content

Instantly share code, notes, and snippets.

@jansowinski
Last active February 19, 2017 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jansowinski/8560e03e3e3147d290cd1608f7803317 to your computer and use it in GitHub Desktop.
Save jansowinski/8560e03e3e3147d290cd1608f7803317 to your computer and use it in GitHub Desktop.
Simple sinatra solution for syncing github repo with external ftp server
load 'ftp_sync.rb' # use this library -> https://github.com/ashchan/ftpsync
require 'sinatra'
# Here you set global ip of your vps
set :bind, '0.0.0.0'
# Here you set port
set :port, '80'
# here you set FTP host
host = 'example.com'
# here you set FTP user
login = 'admin@example.com'
# here you set FTP password
password = 'password'
# here you set your repo path on server
local_path = 'www'
# here you set your ftp targer path
ftp_path 'www'
# Here you set /path which you provide in github webhooks.
post '/path' do
# You need ssh key generated by server.
# You set github deploy-key
# to your's server public key.
anwser = `cd #{local_path} && git pull`
ftp = FtpSync.new(host,login,password)
ftp.sync(local_path, server_path)
anwser
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment