The thoughts of G. Allen Morris III

# Using gitlab.com to publish your website.

February 24th 2018

This morning I decided that it was time to clean up this little blog.

One of my problems is updating the site, but with gitlab it is quite easy to set a hook to get it to publish the web site for me after each push.

To get each push to update our web server we create an .gitlab-ci.yml file with the following text in it.

image: ruby:2.3

before_script:
- gem install bundler --no-ri --no-rdoc
- bundle install --jobs $(nproc) "${FLAGS[@]}"

stages:
- build
- test
- deploy

update_server:
stage: deploy
script:
- rake update
only:
- master
tags:
- docker


And in my Rakefile I have

require "net/http"
require "uri"

uri = URI.parse('https://www.gam3.net/cgi-bin/update_blog?secret=' + ENV['SECRET'])

desc "Update the web server."

Now after every push an endpoint is called by gitlab. By adding more code to the .gitlab-ci.yml file I can have it test the code before it called the endpoint, or only update the server when a particular type or tag is pushed.