Last active
February 19, 2017 21:16
-
-
Save jansowinski/8560e03e3e3147d290cd1608f7803317 to your computer and use it in GitHub Desktop.
Simple sinatra solution for syncing github repo with external ftp server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = '[email protected]' | |
# 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