Skip to content
Permalink
Browse files

Add a blog post on how to deploy using s3 and travis (#9)

* Add a blog post on how to deploy using s3 and travis

* Add ignore for this website with htmlproofer check
  • Loading branch information
mjohnsey committed Oct 14, 2018
1 parent c2a42cd commit c2a5fc7ba6f3a99a4130c35f9e9587b54d8ee61b
Showing with 44 additions and 2 deletions.
  1. +2 −1 _layouts/home.html
  2. +39 −0 _posts/2018-10-13-so-pushy.md
  3. +3 −1 scripts/cibuild
@@ -15,7 +15,8 @@ <h1 class="h0 inline-block py-2 mt-4 header-title">{{ site.title }}</h1>
</div>
</header>
<div class="container mx-auto px-2 py-2">
{% for post in site.posts %}
{% assign first_posts = site.posts | slice:0, 2 %}
{% for post in first_posts %}
{% include post_block.html %}
{% endfor %}
</div>
@@ -0,0 +1,39 @@
---
title: "So Pushy"
subtitle: "Deploy to S3 on Travis Build"
layout: post
date: 2018-10-13 23:00
---

This site is usually a way to try open source tools and to have a link dump for my contact information. I don't write as much as I'd like because pushing to prod takes a few extra steps on a laptop with AWS S3 credentials setup.

This website is currently a Jekyll static site and my goal for a while has been to figure out how to get the site to deploy this site on a push to `master`.

Setting up a Jekyll build on Travis is as easy as getting a Ruby environment setup and running the correct commands. You can find my Travis config file here: [https://github.com/mjohnsey/michael.johnsey.me/.travis.yml](https://github.com/mjohnsey/michael.johnsey.me/blob/95337a40c221d6e66defdfbf9f3fd3a86b447e5e/.travis.yml).

I generated the `deploy` block of the Travis config using the [Travis CLI](https://github.com/travis-ci/travis.rb). It steps you through all the necessary steps. The only thing I added after the fact was `skip_cleanup: true`.

Run this, being sure to encrypt your secret access key:
```bash
gem install travis
travis setup s3
```

It will generate the following yaml in your config:
```yaml
deploy:
provider: s3
access_key_id: AKIAII2S3GRPXDR4R7NQ
secret_access_key:
secure: YtODIzpufOI7w7e4mEsvpE9AtDMvkw6R69dlKMa7+s90ASkWduDlUpKketPRYVmF5VJG0xyYE9iTNK8Vw9LiS/Ad0wY3U/tSAYho1vUcbsg8wZh04BuhHCoxQo+Sq2Z2myMqHh+98I/vvvqyiee5fcWMuhDYS68zz301T8YjtvPRJ29DI1+suA2NaAZKt158BPi0mwafmBNqQcMoFFtPy78RTOtdIO9W7CDTu53Trn6SK/UGAdRVTytZU5kF/FdopLeAWoD/fQlAEiV/rc6IAhEY45cVpYsbWAZXZ1QdHr1dmEB46H/oqx80yL+4T1yb19lo80Trvb/HhSUVYfdil4ld3/taLXYFXPs+H9w30VxATGHdUxrKt49z1eMxrefmQxTZ0kAW1nLmqfidTl0AlN8zLi65QlQi1kIH2Jt7p8b5XIHN2UWM3/W0tNOChNj/qCLl2n8BqMr0NhNdtZalI5avFp3Cs7lKo5qLKC9IQg3xZYIJ+WP7SbsCLJSrDIje66RrP3shtDM4+UCzoxYIX6G1mm1gYODcQ+E/vHUDTqmG8oaCZ/FPpbppJb6WL39rvEGPZtb6YUFjwdZGznhygfnFwEcRnP/fxmMqAeZO6ck2N7yyIED8EH/zcTEREoyzRonK4K+EulilgvNE0WESE+3lRRZTEW9ujUXYjfD9p1Y=
bucket: michael.johnsey.me
local-dir: _site
acl: public_read
on:
repo: mjohnsey/michael.johnsey.me
skip_cleanup: true
```

Setting up the S3 permissions in AWS IAM was the biggest hiccup I encountered but luckily this [blog post from Michal Frystacky](https://medium.com/@michal.frystacky/static-site-github-to-s3-770953a90f67) had an example of the permissions necessary to make it work. I think my problem originally was I did not give ACL permissions to the AWS user I setup for Travis.

Now on every push to master it will deploy the `_site` folder to the S3 bucket. This should open up my ability to write more since I can easily do it from Github's editor. The only thing I have left that I might go back and add later is an invalidation script to clear out my CloudFront after a deploy.
@@ -2,4 +2,6 @@
set -e # halt script on error

bundle exec jekyll build
bundle exec htmlproofer ./_site
# Have to ignore this website because it will keep it from deploying new pages since the new page doesn't exist yet
# (Computers, amirite?)
bundle exec htmlproofer --url-ignore "/michael.johnsey.me/" ./_site

0 comments on commit c2a5fc7

Please sign in to comment.
You can’t perform that action at this time.