Ein Baum und seine Abenteuer

Deploy a hexo blog from Github using Travis

Straightening a lot of things out at the moment I got stuck with my blog.

This should be about the fourth blog I have run in my life. And so far the longest standing one. Mainly thanks to my stay in China. And it has gone through multiple stops so far.

First it was a wordpress powered blog hosted on my webspace at der-grüne-baum.net. That rapidly turned into a maintenance nightmare of "Wordpress needs a security update". So in September of 2015 I took a look around for alternatives and found Hexo. A Node based static blog generator. Technology wise totally my thing and static means pure HTML files without so much security stuff going on. So I switched to Hexo at first uploading by hand via FTP. Last year while I stayed in China the manual upload didn't work so great anymore. The connection just didn't take it. So I moved my blog to GitLab. They had native support for Hexo based sites. I never managed to get the domain moved to there however. So now in 2017 I set out to go for the new domain hoverbaum.net and have it there.

I wanted to still use Git but have things under my own domain. Since I couldn't find the A record thingy for my domain withing a few minutes I decided that it should be possible to upload to my webspace via FTP through some continuous integration. So here is how to do that.

Read on 😉
Read on 😉

Let me tell you a few things I learned during the afternoon of setting this up.

Travis has a page about Custom deployment and that already mentions the use for curl to upload a file via FTP. Now we don't want to only upload a single file but a bunch of files. Namely the entire public folder which contains the generated site.

Some googling brought me to Stackoverflow where I learned that you can use find to get all files and use the -exec command to do something with each file. However the -exec must be closed with a ";" which typically gets escaped using ";". But that doesn't work for YML. I got around this by escaping it using "s instead which means I had to change the surrounding "s to 's.

Looking further at the last line the $FTP_USER and $FTP_PASSWORD are straight forward environment variables. Those should be configured in Travis and be set to not show during runtime. Or else other people will be able to get username and password for your server. Lastly the weird {} parts are referencing the original path of a file. This leads to everything being uploaded to yourFolder/public/FILES. I couldn't get that the upload to yourFolder/FILES so I changed where my domain pointed. You can't have everything be perfect.

Feel free to use my travis.yml file. Make sure to follow the steps in the comments up top.


Portrait picture of Hendrik

I am a JavaScript and GenAI Enthusiast; developer for the fun of it!
Here I write about webdev, technology, personal thoughts and anything I finds interesting.

More about me

Read next

Building Electron based applications using CIs

BlankUp, my first Electron based application
BlankUp, my first Electron based application

One of the new cool kids on the block of webdev is Electron. With it we can build native apps using what we are best at: websites.

Electron simply wrappes websites to create native applications for Windows, Linux and Mac. Sounds wonderful, right?

Ohh yes and it is a lot of fun building something with Electron. Until one fine day you think you are done and want to "publish" your work. Well here it gets really rough. At least it got for me, so let me tell you my story and get you started.

Running a blog in China

Chinas great wall didn't cause me trouble but the great firewall did.
Chinas great wall didn't cause me trouble but the great firewall did.

Reader of my adventures in China beware! This post is in English and will get technical. You have been warned.

Turns out running a blog in China is not the easiest thing. Well actually running a blog in itself is quite some work but that is a different topic.

Holiday greetings with GenAI

Festive Greetings - ChatGPT and Midjourney
Festive Greetings - ChatGPT and Midjourney

Happy Holidays and festive greetings, powered by ChatGPT, Midjourney and a little bit of Photoshop.

Utilizing my Custom GPT for Midjourney prompts (open source on GitHub), I generated the image and some subtle variations in three rounds. Finally touching it up with a tagline in Photopea.