source("_helpers.R")
GitHub supports "Webhooks" to notify you of changes. In their own words:
Webhooks allow you to build or set up integrations which subscribe to certain events on GitHub.com. When one of those events is triggered, we’ll send a HTTP POST payload to the webhook’s configured URL. Webhooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. You’re only limited by your imagination.
Since so many R packages are developed on GitHub, this can be a useful integration. You might want to have R respond to new issues created for a repository, evaluate changes to data or code on GitHub, or just about anything else you can imagine.
The best guide to setting up a GitHub Webhook is the official documentation page. In brief...
application/x-www-form-urlencoded
, and enter a secret key.At this point, any commits that are pushed to that repository will trigger a POST request to the URL you specified. You can use code like the example below to respond to these triggers.
In this example, we'll demonstrate how to setup an plumber endpoint that is capable of listening for Webhook notifications from GitHub. The example will simply subscribe to push
notifications on the plumber repository (which are triggered any time a commit is pushed to that repo) and, in response, will install the most up-to-date version of plumber.
We'll add one additional endpoint that enables us to see what version of plumber is installed on the system at that moment. You should find that the sha1
value of the response matches the latest commit hash in the main branch of plumber.
GET https://demo.rplumber.io/github/version
Click "Get" to see the response.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.