Skip to main content

Working with GitHub Apps

Creating a new GitHub App​

For creating a new GitHub App for the AgrospAI organization, go to the https://github.com/organizations/AgrospAI/settings/apps/new.

You can use whatever home page URL you want, for example https://agrospai.udl.cat.

You can activate Webhooks to send events to your server. For example, you can have a server listening to events on https://agrospai.udl.cat/webhook.

Warning: Because the endpoint is public, you should use a secret to validate the source of the events.

Validating the source of the events​

GitHub doesn't send the raw token in the headers, it sends a X-Hub-Signature and X-Hub-Signature-256 headers instead.

Follow the official documentation to validate the token.

Check events sent by the GitHub App​

Go to the Advanced tab on the GitHub App settings, which is something like https://github.com/organizations/AgrospAI/settings/apps/agrospai-argo-events/advanced.

Get information about the GitHub App​

App ID​

You can find the App ID in the General tab of the GitHub App settings, which is something like https://github.com/organizations/AgrospAI/settings/apps/agrospai-argo-events

Private key​

You can't see an existing private key, but you can create a new one on the General tab of the GitHub App settings.

Webhook secret​

You can't see an existing webhook secret, but you can replace the current one on the General tab of the GitHub App settings.

Installation ID​

Go to the specific GitHub App on the installations page, which is something like https://github.com/organizations/AgrospAI/settings/installations/ and you will find the installation ID in the URL.

Authenticating as a GitHub App​

You can't clone (or any other action that needs permission) private code directly from a GitHub App private key. You need to generate a JWT each time you want to authenticate as a GitHub App (it expires after 1 hour).

Check the official documentation for more information.

We use a custom script to get the installation token. You can find it in apps/github-toolkit.