A Blog
This is the first post of my new blog at blog.ad-schmidt.de. You probably already noticed that.
Motivation
So how did this blog come to existance? I did some recent projects (building and programming a new keyboard, developping an android widget) and wanted to write about it. As I write these lines the android widget is still not finished, so it is also a means to keep me at it. So that I can finish this side project while also working on my main job.
Tech stack
Without much research I knew, that I wanted to use a static site generator where I could write my posts in Markdown. So I stumbled upon Hugo and thought it is worth a try.
I then looked at all the available themes and chose the quite minimalistic Hugo Bear Blog.
Thankfully there also was already a guide how to install Hugo on my Uberspace. This was quite straightforward, so now I am here having my blog up and running just after a few hours.
Hopefully I will find some more time to customize the theme to my liking (adjusting colors and so on). However, I hope you will not find many posts for the #hugo-tag in this blog, as this would mean that I am doing more work on configuring the blog than filling it with content.
Git
When using a static side generator and being a developer it is quite obvious to use git to store all the content, configuration, etc. so this is also what I did for this blog. You can find the corresponding repository on GitHub.
Even as nobody knows of this blog (yet) I still wanted to have a test-environment to try new layouts or to publish my content to, before deploying it to the real page. So I also created a separate branch for the pre-prod environment.
My desired workflow is to write content or play around with customizations in the pre-prod environment and only merge the changes to the main-branch once they are ready to go live.
The minimalistic CI/CD pipeline
So having this setup with at least 2 branches I tried to come up with the simplest continous delivery pipeline:
- When I push a commit to the pre-prod branch it should be displayed at pre-prod.blog.ad-schmidt.de immediately
- When I push a commit to the main branch it should be displayed at blog.ad-schmidt.de immediately
Basic setup
The combination of the default setup of an uberspace (having one directory for every subdomain) and the static site generator make it easy to write a small script that can deploy the currently checked out content directly.
So now all that is left to be done when there is new commit is:
- Do a git pull on my uberspace
- Run the deploy script
The initial trigger for this could be a GitHub webhook, so I started reading up how those work.
GitHub Webhooks
GitHub can send Webhooks for just about everything that happens in a repository. For my use case a simple hook for each push is enough.
This means, that I need to provide an endpoint at my web space to be called from GitHub, so I used another subdomain api.ad-schmidt.de and wrote a small flask-app to perform the necessary actions.
Fortunately there is guide how to install flask on an uberspace. So this app checks the webhook payload, validates the secret and then pulls from github and executes the deploy-script.
You can have a look at this mini-api-application on here
Summary
So now that everything is up and running I will continue to work on my small android widget and write about it here. Let’s see what comes after that.