Gitano is a Git server, which happens to be the one that hosts ick’s own source code. Gitano supports post-receive hooks: bits of code that get run after a user does git push. This can be used to trigger a CI build, whenever a repository gets modified.

Here is an example. It’s a Lua script. To use it, clone the Gitano admin repository (gitano-admin), and create the file global-hooks/post-receive.lua in the master branch. Put the code below into that file. Commit and push to the server. After this, any git repository on that Gitano instance that has the Gitano per-repository configuratution variable ci.notify_url causes the configured URL to be fetched (using GET), which in this case triggers ick to build the relevant project.

To set the configuration variable:

url=https://ick.example.com
project=ick.liw.fi
pipeline=build_ikiwiki_site
ssh git@gitano config ick.liw.fi set ci.notify_url \
    "$url/projects/$project/pipelines/$pipeline/+trigger"

(Split into multiple statements so it fits in 80 columns.)

The post-receive Lua hook script:

--
-- This is a global hook for a Gitano instance.
-- It should be installed as gitano-admin::global-hooks/post-receive.lua
--
-- It's meant as a simple CI trigger


local project_hook, repo, updates = ...

local do_notify = false

for ref in pairs(updates) do
   if not ref:match("^refs/gitano/") then
      do_notify = true
   end
end

local ci_notify_url = repo:get_config("ci.notify_url")

if ci_notify_url then
   log.state("Notifying CI at: " .. ci_notify_url)
   local code, msg, headers, content = fetch(ci_notify_url)
   if code ~= "200" then
      log.state("CI notification failed: " .. tostring(code))
   else
      log.state("CI notification succeeded.")
   end
   for line in (content or ""):gmatch("([^\r\n]*)\r?\n") do
      log.state("CI: " .. line)
   end
end

-- Chain to the project hook if there is one
return project_hook(repo, updates)