I finally got Travis working with my website.
The challenge I had was that one.com for some weird reason
rsync via passwords over ssh, not public/private keys.
This does not just work outside the box since
rsync over ssh will under normal
circumstances require a user to type in the password.
Luckily there is this little tool called
sshpass that can help.
The following describes how to get all this to work together in Travis.
In my .travis.yml
I did the following:
language: ruby bundler_args: "--without development --path .bundle" rvm: - 2.2.0 addons: ssh_known_hosts: ssh.xam.dk // (1) branches: only: - master before_script: - sudo apt-get install -qq sshpass // (2) script: rake travis // (3) env: global: secure: fpWVLgbveBCXlsXX7ef06qi7GrizwAE5MFq5pKH9G5AMFAdFL4xQxNOmeemRZ5fnMAn8LQUrA8otxwjiiq2RangRC9E11fBChEKC5V+FewBzsHONqkSTzKd6oAbmLynUizpXDofhVxIfRhtP03lfEDufzly4WaVDyoLJicvy9aM= // (4)
Add your host to ssh_known_hosts to avoid 'Host key verification failed' error
sshpassbefore starting the build
Run rake script that does the actual
Created secure variable by running
travis encrypt XAMSSH=secretpassword --add
Travis rake task
And then in the
Rakefile I added my travis task
that does the actual
desc 'Task to be used on travis-ci' task :travis do run_awestruct("-P production -g --force") puts "## Deploying website via rsync" success = system("sshpass -p $XAMSSH rsync -rvc --delete --exclude coppermine --stats --exclude update _site/ email@example.com:/www") // (1) fail unless success end
The important part is
sshpass -p $XAMSSHwhich uses the encrypted value from travis.
Voila - now my website will get automatically built with awestruct and
synchronized with rsync even though one.com don’t like
to provide more secure private/public keys.