Search code examples
githubwebhooksgithub-api

Repository-Webhooks vs Github Apps - which to use?


UseCase: My current use case is to react on new Issues and post automatic comments. This is mainly specific to one or two repositories.

Thus I guess webhooks on a repository as well as Github Apps can be used. Although Github has some really good documentation on both, I'm unsure which one to use for my scenario.

What advantages / disadvantages do they have when compared?

  • One advantage of Github Apps is that they don't need to add a WebHook to the repository according to this answer. - Not sure why that is an advantage.
  • Obviously a GitHub App can be installed in different repositories and also published in the marketplace. But I could also use the same URL for Webhooks in different repositories and thus mimmic that behavior with repository-webhooks to a certain extend.
  • What else?

Solution

  • The main difference is that while webhooks generate events and send them to a given URL Github. Apps have the right to access the repositories where you install them based on the permissions you give them.

    If you have a webhook that fires every time an issue is updated you will receive an event at the URL you specified, but you will not have any rights to e.g. modify that issue in Github (e.g. through an API call).

    If you instead have a Github App installed in your repository and the webhook URL set in the App settings, then the event will be sent to the URL as well. However, here's the difference: behind the webhook URL you will probably have a service that uses the Github App credentials (private key or temporary tokens) to make some modifications to your Github repo.

    An example:

    • Webhook -> logging of Pull Request changes
    • Github App -> automate tagging of new pull requests