Hacker News new | ask | show | jobs
by deca6cda37d0 2433 days ago
“ I use the GitHub Actions beta to automatically update the public site every time I commit to master.”

How do you set that up?

6 comments

It's somewhat convoluted and custom to my specific hosting setup (I use https://www.nearlyfreespeech.net because I want an Apache server so I can use complex redirects). Essentially, the GitHub Action builds the site and then copies it over to NFSN. This is all done in a Docker container.

The only potentially interesting part about this setup is I take advantage of this git feature I didn't know about until I set this up: https://git-scm.com/docs/git-worktree. This lets you essentially check out a branch into a folder in a repo. Hugo can then build the site in to the special folder, and the built site is committed just to that branch. I then push this branch to NFSN, rather than using rsync or scp, which takes a lot longer for small changes compared with sending a git delta over the wire.

I plan to write up a more extensive description of this when GitHub Actions come out of beta. If you want to hear about it when it comes out, you can subscribe to my blog's newsletter: https://masnick.blog/subscribe/

If it's not too much to ask, I would add on here that I'd like to see your Hugo setup. I've been learning it recently but the examples I find are all rather simple. Just seeing what you've done gives me some ideas of how you did it, and I'll work on figuring it out - but information on how you organize things before hugo generates the site would be greatly appreciated.
Unfortunately I don't have a good way to reveal the source of my site as there are some things in that git repo that can't be made public.

I too have struggled to find examples of doing more complex things in Hugo. It's such a versatile tool that it's probably pretty hard to document everything in an approachable way.

I may write up how I set up the Hugo portion of the knowledge base as it has worked quite well. If I do, you can subscribe here to make sure you see it: https://masnick.blog/subscribe/

I understand. I'll subscribe - and just looking over the parts of the site and going back to the documentation has helped me to wrap my head around a few things that were eluding me.

Thanks for the response, I appreciate it and I'm really glad you took the time to post your original answer. It's a real help to me in ways I didn't expect when I clicked into this thread.

You can refer to GitHub Actions for Hugo https://github.com/peaceiris/actions-hugo
You could instead use Gitlab with their CI/CD tool: https://gitlab.com/pages/hugo
I haven't tried GitHub Actions yet, but Netlify makes this very easy to do.
Yes, unless you have my weird requirement to use an Apache server, I think something like Netlify or GitHub Pages makes way more sense.
Very interested in this as well. How do you do automatic deployments?
I described this briefly in a reply to the parent: https://news.ycombinator.com/item?id=21316442