<commit_before>---
layout: post
title: Jekyll and Continuous Deployment
---

Having changed this site from WordPress to [Jekyll](http://jekyllrb.com) I thought it would be good to have some kind of automated deployment, so I could just `git commit` and push, and have the changes go live automatically.

Jekyll's documentation has a section on [Continuous Integration](http://jekyllrb.com/docs/continuous-integration/) which gives a good overview of how to make [Travis](http://travis-ci) build and test your site for you but it doesn't talk much about deployment steps. (There is a [page about that](http://jekyllrb.com/docs/deployment-methods/) but it doesn't tie it all together much.)

So here's how I'm doing it.

### High-level overview

My webhost limited SSH connections to a few trusted hosts, so I could have set up Travis to do SSH-based deployment via a jump host. However, I decided to get Travis to put the deployable site somewhere and then poke the server to fetch it. Travis deploys the built `_site` folder to an S3 bucket, and then I use the webhook notification method to kick off a script on the server. The script downloads the S3 bucket to a temporary folder, and then swaps symlinks around to point the webserver at the new version. Both the Travis build and my script send notifications to a Slack instance for me to keep an eye on things.

### Travis config

There's two main parts to the `.travis.yml` file to make this work. The first is to deploy it to S3:

{% highlight yaml %}
deploy:
  provider: s3
  access_key_id: [snip]
  secret_access_key:
    secure: [snip]<commit_msg>Fix typo<commit_after>---
layout: post
title: Jekyll and Continuous Deployment
---

Having changed this site from WordPress to [Jekyll](http://jekyllrb.com) I thought it would be good to have some kind of automated deployment, so I could just `git commit` and push, and have the changes go live automatically.

Jekyll's documentation has a section on [Continuous Integration](http://jekyllrb.com/docs/continuous-integration/) which gives a good overview of how to make [Travis](http://travis-ci) build and test your site for you but it doesn't talk much about deployment steps. (There is a [page about that](http://jekyllrb.com/docs/deployment-methods/) but it doesn't tie it all together much.)

So here's how I'm doing it.

### High-level overview

My webhost limits SSH connections to a few trusted hosts, so I could have set up Travis to do SSH-based deployment via a jump host. However, I decided to get Travis to put the deployable site somewhere and then poke the server to fetch it. Travis deploys the built `_site` folder to an S3 bucket, and then I use the webhook notification method to kick off a script on the server. The script downloads the S3 bucket to a temporary folder, and then swaps symlinks around to point the webserver at the new version. Both the Travis build and my script send notifications to a Slack instance for me to keep an eye on things.

### Travis config

There's two main parts to the `.travis.yml` file to make this work. The first is to deploy it to S3:

{% highlight yaml %}
deploy:
  provider: s3
  access_key_id: [snip]
  secret_access_key:
    secure: [snip]
{'fraction_non_alphanumeric': 0.06550218340611354, 'fraction_numerical': 0.002495321272613849, 'mean_word_length': 4.189320388349515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '932443', 'n_tokens_mistral': 896, 'n_tokens_neox': 851, 'n_words': 492}