GitHub
Introduction
In this guide we'll walk through the process of linking Cerb to GitHub. You'll be able to use GitHub's full API from bots in Cerb to automate whatever you need.
GitHub Authentication
There are two alternative authentication methods when using the GitHub API.
-
Personal Access Tokens: A long-lived secret token for a specific GitHub user. Rotating the token must be done manually. This is the simplest option.
-
OAuth2: A short-lived access token and long-lived refresh token. This allows multiple GitHub users to link their account to Cerb. It requires a more involved OAuth application setup, but is the most secure option since secret rotation is automatic and indefinite.
Method 1: Personal access token
Create a personal access token at GitHub
To create a personal access token, log into GitHub.
Click on your profile image in the top right.
Select Settings from the menu.
Select Developer Settings in the left sidebar.
In the Personal access tokens section, click the "Tokens (classic)" button and then Generate new token.
Name the token, set an expiration period, and select the necessary scopes for your needs.
Click Generate token and copy down the token you are provided.
Create a connected service in Cerb
In Cerb, navigate to Search » Connected Services » (+) and select the Build tab at the top.
Field | |
---|---|
Name: | GitHub (Access Token) |
Type: | Token Bearer |
Token Name: | Bearer |
Click the Save Changes button.
Create a connected account in Cerb
In Cerb, navigate to Search » Connected Accounts » (+).
Select GitHub (Access Token).
Choose any name (e.g. GitHub (example-user)
) and URI (e.g. GitHub-example-user
).
In Token: paste the personal access token you generated at GitHub in the first section above.
Click the Save Changes button.
Test the connected account in automations.
Method 2: OAuth2
Create an OAuth application at GitHub
Review the GitHub OAuth documentation additionally if needed.
-
Visit the GitHub OAuth applications settings page.
-
Click the green Register a new application button.
- Enter the following details replacing
YOUR-CERB-HOST
with the URL to your Cerb installation:- App Name: Cerb
- Homepage URL:
https://YOUR-WEBSITE
- Application description: {leave blank}
- Authorization callback URL:
https://YOUR-CERB-HOST/oauth/callback
-
Click the Register application button.
- Make a note of your Client ID and Client Secret for the next step.
Create the GitHub service in Cerb
-
Navigate to Search » Connected Services.
-
Click the (+) icon in the top right of the list.
-
Select GitHub.
-
Enter your Client ID and Client Secret.
-
Click the Create button.
Link the connected account to GitHub in Cerb
-
Navigate to Search » Connected Accounts.
-
Click the (+) icon in the top right of the list.
-
Select GitHub.
-
Click the blue Link to GitHub button.
-
Accept consent on GitHub.
-
Click the Save Changes button.
Use the connected account in automations
You can use the connected account you just created to access GitHub's API within automations in Cerb. This is typically accomplished using the http.request: command and using the connected account in the authentication
field.
You can import the GitHub Issues workflow for a working example.