On the dashboard for your new web app, make a note of the FTP host name and your deployment credentials. If you’ve forgotten your deployment credentials you can reset them from here as well.
I know I said earlier that I didn’t want to use GitHub, but I’m not actually using GitHub Pages. Travis depends on GitHub Webhooks in order to figure out when you push an update to your site and kick off a build. In addition to the standard Jekyll files you’ll need to add a
.travis.yml configuration file as well as a build and deploy script. My Travis configuration looks like this:
language: ruby rvm: - 2.2 script: - chmod +x script/build - ./script/build after_success: - chmod +x script/deploy - ./script/deploy env: global: - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
Taking it section by section
language: ruby rvm: - 2.2
This tells Travis that the project is Ruby based, and what version of Ruby to use - in this case Ruby 2.2.
script: - chmod +x script/build - ./script/build
My build script in the
scripts directory. This sets the execute flag, then executes it.
after_success: - chmod +x script/deploy - ./script/deploy
If the build is successful, Travis will set the execute flag on the
deploy script, then execute it.
env: global: - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
html-proofer to check all the links and images on my site, and this allows me to speed up the build time by using pre-installed libraries.
Now onto the
build script. There’s nothing terribly exciting here, just build the site and run
html-proofer on it.
bundle exec jekyll build bundle exec htmlproof ./_site
The real magic happens in the
sudo apt-get install -qq ncftp ncftp -u "$USERNAME" -p "$PASSWORD" $HOST<<EOF rm -rf site/wwwroot mkdir site/wwwroot quit EOF cd _site ncftpput -R -v -u "$USERNAME" -p "$PASSWORD" $HOST /site/wwwroot .
I’m making use of a handy program called
ncftp in order to deploy my site. Firstly Travis deletes the currently deployed site, then puts the generated Jekyll site on the FTP server.
To put it all together you need to configure Travis builds for your GitHub repository, and set the environment variables to allow Travis to deploy to Azure:
USERNAME requires a double backslash to escape the character in the terminal.
Now that everything is all configured all you need to do is push a commit to GitHub and wait. If everything is good you should see your Jekyll site deployed automatically to your Azure Web App - though if you’re anything like me
html-proofer will have picked up some broken links on your site!