GitHub WebHooks triggered globally instead of per branch -
our product creates webhooks @ github. 1 each customer project.
each such project, linked single branch.
when push
github performed, corresponding webhook triggered, in turn, making request endpoint on our side perform action.
a common scenario customer have several projects, connected several different branches of same repository. hence, several different webhooks connected same repository.
the problem when push
performed 1 of branches, github triggers repository related webhooks.
we expect when push made branch, single corresponding webhook triggered.
i found 2 posts (one of them 2012) seem refer problem:
a possible solution parse ref
parameter sent inside webhook request , control when take action accordingly (haven't checked direction yet, , hope ref
indeed exists , holds right branch path/name). "too late" - cause webhooks have been triggered then...
but seems unreasonable github wouldn't have way configure behavior somehow.
help appreciated.
i've reached out github support.
i hope post others, misunderstand relation between webhooks , repositories / branches.
here's answer:
the behavior observed expected , there no plans change in near future.
when create webhook on repository , subscribe push event -- webhook trigger when branch or tag pushed to, documented here:
https://developer.github.com/v3/activity/events/types/#pushevent
there no per-branch webhooks.
so, instead of creating multiple webhooks subscribed on push event on same repository, should create one, , check branch pushed payload receive (as noticed, name of branch passed via ref field in payload).
this answer made realize our conception wrong.
branches not mapped webhooks. each webhook linked repository, , when commit branch made, branch stated inside ref
attribute inside webhook web request, this:
{ "ref": "refs/heads/branch_name", ...
another thing note github limits number of webhooks created per repository-event:
you can create 20 webhooks each event on each installation target (specific organization or specific repository).
it taken here:
https://developer.github.com/webhooks/
that's important in context, cause creation of webhook per branch push
event, made reach limit of 20 webhooks, causing errors when trying create additional webhooks.
keeping @ 1 webhook per repository eliminate problem.
Comments
Post a Comment