Alex Urquhart
Geomatics Professional

Deploying My Site With Gogs

Tags: linux git gogs hugo

Go Git Service (Gogs) logo

As I’ve written about before my current blog is a static site generated with Hugo. Being a static site, with no dependencies it is incredibly easy to set up a method to deploy your site using git push. An in-depth article on this workflow was published by DigitalOcean and is what my method has evolved from over the past few months.

I recently installed Gogs, or “Go Git Service”, which is a lightweight, self hosted GitHub clone that I will be using to host my personal projects that I don’t want to share with you fine people. One thing that I discovered is that Gogs offers a web-based interface to edit all the available Git hooks, so now when I git push my website from my desktop or cloud IDE to my Gogs instance, I’ll be able to auto-deploy my site as well!

A list of Git hooks available in Gogs.
A list of Git hooks available in Gogs.
The post-receive hook I use to deploy my site.
The post-receive hook I use to deploy my site.

The Hook

The post-receive hook that I use is simple, you may recognize it if you’ve followed the DigitalOcean tutorial.

#!/bin/bash
git --work-tree=/var/www/alexurquhart.com/ --git-dir=/home/git/gogs-repositories/alex/alexurquhart.com.git checkout -f

While I have my reservations about allowing arbitrary bash scripts to be entered from the web, using these hooks on private gogs instances would easily allow you to initiate automated tests or builds, CI tasks, or the deployment of more complicated applications given the proper setup.

comments powered by Disqus