Minimal Git CI using hooks

Lobsters Hottest Tools

Summary

A blog post describing a minimal CI system using Git hooks and nq, a lightweight job queue, for personal git repositories.

<p><a href="https://lobste.rs/s/jr72dt/minimal_git_ci_using_hooks">Comments</a></p>
Original Article
View Cached Full Text

Cached at: 07/20/26, 09:34 AM

# Minimal Git CI using hooks Source: [https://mccd.space/posts/26-06-29/simple-git-ci](https://mccd.space/posts/26-06-29/simple-git-ci) I have a personal server where I am hosting my git repos\. Setting up a new git repo is easy: I ssh into my server, cd to a new directory and run`git init \-\-bare`\. That's it\. Cloning my newly created repo is simple as`git clone server:/home/me/repo`\. For some projects I've needed a CI, and I looked around for some existing solutions\. The CI systems I found are convoluted, yaml\-ridden, slow, messy or hard to self\-host\. Luckily, I do not need many "modern" CI features like complete isolation for my builds or secret management\. I just need something that runs some tests, builds a project or moves some files\. What I have settled on is a simple CI using[git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)\. Specifically, I added a remote`post\-receive`hook, which is a hook that runs whenever I push to a project\. It is just a shell\-script that I add to the`hooks`directory in a bare git repository\. The thing to watch out for with`post\-receive`hooks is if the script fails, the code you push will be rejected\. Also, if the script is slow, pushing will take a while\. You generally don't want either\. I solved this by using[`nq`](https://git.vuxu.org/nq/about/), a minimal job queue, to queue up my jobs in the background instead\. The result is quite sleek: my post\-receive hook just executes`nq`, and I can access the logs by running`ssh server nqtail \-a`\. The CI runs instantly, and is very easy to set up, so I am happy with the result\. If you'd like to set it up for yourself, I created a short[tutorial](https://mccd.space/wiki/tutorial-git-repo.shtml)\. There are many ways you could expand the base I provide in the tutorial: you could sandbox the builds \(for example with[landdown](https://mccd.space/git/landdown/file/README.md.html)\), use podman to isolate builds from the environment, or use[sops](https://github.com/getsops/sops)to manage secrets\. For bazaar\-style development, receiving git patches via email should be enough\. You can also set up cathedral\-style development using git\-shell or git http\-backend\. [Reply](mailto:[email protected]?subject=Re%3A%20Minimal%20Git%20CI%20using%20hooks)

Similar Articles

Ask HN: Alternatives to GitHub

Hacker News Top

A Hacker News discussion thread exploring alternatives to GitHub, with users sharing self-hosting experiences with GitLab and comparing CI/CD solutions.

Git at Any Scale (27 minute read)

TLDR AI

This article explains the difficulties of hosting Git repositories at scale, focusing on Git's packfile design and distributed nature, and outlines potential solutions.

Local Git Remotes

Hacker News Top

A tutorial on setting up local git remotes using bare repositories for personal projects, allowing offline-friendly push/pull workflows.