An IRC bot written in the Perl 6 programming language, to announce GitHub commits to various channels.
The webhook endpoint is https://geth.svc.tyil.net/?chan=#perl6 where #perl6
is the channel to report the commits to. Multiple channels can be specified,
separated with commas.
To add commit filters stick a .pm6 file into commit-filters/
and make it contain 1 sub that takes 1 arg with a name.
- Return undefined value to signal that filter did not match;
- Return a
Falsevalue to stop further processing of the event and do not send any response to IRC; - Return a string to send it to IRC.
Put the URL of the sourcehut hook in a shell var:
hook_url=XXX
Create a token via the web UI and also put it in a var:
oauth_token=XXX
Look up the ID of the repo you're interested in with:
curl \
--oauth2-bearer "$oauth_token" \
-H 'Content-Type: application/json' \
-d '{"query": "{ me { repositories { results { id, name } } } }"}' \
https://git.sr.ht/query
Put it in a var:
repo_id=XXX
Then create a webhook with:
curl --oauth2-bearer "$oauth_token" -H 'Content-Type: application/json' -d "{"query": "mutation { createGitWebhook(config: { repositoryID: $repo_id url: \"$hook_url\" events:[GIT_POST_RECEIVE] query: \"query { webhook { event, ... on GitEvent { repository { name, owner { canonicalName } } updates { ref { name } old { id } new { id } log { results { id, diff, author { name, time } committer { name, time } message } } } } }}\" }) { id } }"}" https://git.sr.ht/query