Just Had a Weird Idea

kain

2019-05-01

This blog is built on GatsbyJS, which is a static site generator. The underlying blog posts that I write are just markdown files that sit in a posts directory in the Github repository for this blog. The way the site is built and deployed is really rather straight-forward:

  1. I write my new blog post (like this one)
  2. I run git add/commit/push
  3. I run npm run build (which builds the static site)
  4. I run npm run deploy (which deploys to S3)

That process is straight-forward enough for me that I had not considered continuous deployment options. That is until I visited one of my favorite blogs DodgersDigest. One interesting thing about successful blogs is that they often have multiple contributors, and DoDi is no different. Now, I am not at the scale to necessitate (nor have the need for) multiple writers on this blog. I do not think I wrote a blog post in 2018, for example. However, with the Gatsby setup I have no back-end and therefore no user authentication etc.

So, my weird idea is to leverage Github to do that for me. I am imagining changing my process to the following:

  1. I write my new blog post
  2. I run git add/commit/push

Then have my integrated deployment solution react on Github's webhooks to notify that master has been updated, so then it will:

  1. Run npm run build
  2. Run npm run deploy

I did this; git push origin master now deploys the build to S3 automatically via Travis-CI.

What is interesting about this is that I could actively allow other writers simply by accepting pull requests. See, each of these posts are just markdown after some simple metadata markup:

---
path: "/just-had-a-weird-idea"
date: "2019-05-01"
title: "Just Had a Weird Idea"
---

This blog is built on GatsbyJS, which is a static site generator...

I could very easily build in the notion of an author piece of metadata and start accepting pull requests from anyone. This is interesting enough that I think I will probably do it.

Okay, I did that:

---
path: "/just-had-a-weird-idea"
date: "2019-05-01"
title: "Just Had a Weird Idea"
author: "kain"
---

This blog is built on GatsbyJS, which is a static site generator...

Now, it shows the author name just under the post title (added some sick FontAwesome icons, as well).