Hosted websites, Continuous Integration GitHub and GitLab
Back when I started hosting this blog on GitHub you had two choices. Either you used Jekyll and GitHub would do it's behind the scene magic to convert your markdown files into your site or you did it all on your own machine and you pushed up the finished site to be served under GitHub pages.
I started with the former but moved to the later using Hugo as my site generator soon after. This has worked for years but it's gotten a little messy. I've needed two GitHub repos - one for the source for my blog and the other for the rendered web site and also I've had to use Git submodules - something I never fully understood. This has caused me troubles at times when trying to write posts from multiple machines.
I thought I'd look this weekend to see if things have gotten better.
It turns out, it has. Now, you can just serve your repo as a web page just like before but you can also set up your site using GitHub actions.
GitHub actions is their facility to run some job when something occurs. A typical setup would be to run your tests whenever code is pushed or a pull request is merged. I taught this to my undergrads last semester. Basically, you just set up a configuration file that tells GitHub what to do.
Here's the config file I used with my class for the automated testing:
name: C/C++ CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: make run: make - name: make tests run: make tests - name: ./tests run: ./tests
GitHub spins up an Ubuntu image then builds the project and runs the tests. I get an email with the results or I can see them on GitHub.
Now I can use the same facility for serving this blog. The script runs hugo instead of make and make tests but it's the same idea. Whenever I push a new post, GitHub rebuilds the site and serves it all from one repo.
Much simpler and much cleaner. What's more, when I turned on GitHub pages and selected the "use GitHub actions" option, it suggested I use their "Hugo config script" which worked right out of the box.
While I was doing this I thought I'd also check out GitLab. GitLab is a GitHub competitor. I like them both but since I've had so many friends at GitHub and GitHub education specifically I've always gone that way. Now, my friends have all left GitHub and I can't say I've been happy with all the companies latest moves so I thought I'd check out the other guys.
It turns out GitLab also hosts pages and has a very similar actions based deployment mechanism. I haven't switched over yet and might not but I think I will start using it for my regular repo hosting. It looks like a very nice alternative.
So, if you're looking for hosting, check out GitHub and GitLab with actions. I'd also say that if you're teaching a class at the right level, actions can be great to teach continuous integration and testing. I'll probably write that up when I cover it in class in a few weeks
That's it for now. I'll try to post this. If it works, the changeover from GitHub old style to GitHub actions went smoothly.