Artisan IMG > GitHub (github)

GitHub

Hosting and version control for software projects, making collaborative development much easier.

Overview
Copied!

API INFO: The Base URL used for the GitHub connector is https://api.github.com. More information can be found on their main API documentation (vv3) site. This is where users will also be able to find the API Limitations page.

List repositories and branches
Copied!

Below is an example of a way in which you could potentially use the GitHub connector to list all the branches from each repository

The following workflow gives an example of how you can achieve this:

  1. Steup using a trigger (be it Manual, Scheduled, Callable etc).

  2. The List your repositories is a GitHub connector's operation that lists all your GitHub repositories.

  1. Loop is a Loop connector step to 'Loop List' all the GitHub repositories received from the previous step.

A jsonpath for the 'List' field should appear similar to this: $.steps.github-1.results. You can always use a connector-snake to find the jsonpath.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray.io, please see our Intro page and Data Guide for more details.

  1. List Branches is a GithHub connector's operation that lists branches of GitHub repository based on the provided 'User/Organisation' ($.steps.loop-1.value.owner.login) and 'Repository' ($.steps.loop-1.value.name) names.

It takes jsonpaths for the 'User/Organisation' and 'Repository' field from the Loop step.

The fetched list of branches should look similar to this:

Click on the Debug tab to view Input and Output for individual steps.

Consolidate security information of all
Copied!

PLEASE NOTE: The GitHub account that you authenticate with in the Tray app must have the Owner permission level to view security information. Please visit the GitHub Docs for more information on permission levels.

Below is an advanced workflow that will get the security information of all repositories within your account and store them in a data storage.

In this case, we are using Google sheets as a generic placeholder for any service or database you may wish to use.

The resulting document will look similar to this:

This is what the finished workflow will look like:

  1. Steup using a trigger (be it Manual, Scheduled, Callable etc).

  2. The List your repositories is a GitHub connector's operation that lists all your GitHub repositories.

PLEASE NOTE: The 'List your repositories' operation will return a maximum of 100 repositories per page. If your collection is greater than 100 repositories you will need to paginate. Please refer to the Pagination Docs for instructions.

📋
1
![github-security-info-list-repoo](github-security-info-list-repoo.png)
  1. Loop is a Loop connector step to 'Loop List' results received from the previous step.

A jsonpath for the 'List' field should appear similar to this: $.steps.github-2.results. You can always use a connector-snake to find the jsonpath.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray.io, please see our Intro page and Data Guide for more details.

  1. Get branch protection is a Gaurdian connector step that retrieves protection rules for the branch based on the provided 'Repository' ($.steps.loop-1.value.name)and 'Branch' ($.steps.loop-1.value.default_branch) name.

This step takes jsonpaths from the Loop step.

If the provided repository does not have branch protection the workflow will return an error.

Manual error handling

In this case, you should use Manual error handling method instead.

To do so for the Get branch protection step in the properties panel, click 'Handle errors' and set the error handling to 'Manual'.

The way we handle an error from the Get branch protection step here is:

  • Success: This means GitHub connector has successfully returned the protection information and we can manipulate the payload and then store it into Google sheets (No branch protection step).

  • Error: This means the provided repository does not have branch protection and the GitHub connector has returned no data. In which case, we can pass the branch information from the Loop step directly into the Google Sheets connector (Has branch protection step).

PLEASE NOTE: There is no fixed way of working with error handling. This is just one simple example of handling errors. Exactly how you handle errors depends entirely on your specific requirements.

  1. No branch protection step is a Google Sheets step that will add data from the Loop step into a Google Sheet using the 'Create row' operation. The operation requires 'Spreadsheet ID' and 'Worksheet name' to add data to the specific spreadsheet.

For information on how to set up the Google Sheets connector please visit the Google Sheets Docs.

You can always use a Date Time Helper to make the pushed at and created at values readable.

  1. Has field restrictions? is a Boolean connector step that checks if restrictions 'Property exists' or not. The step accepts 'JSONpath Property' from the Get branch protection step.

If the specified GitHub property exists, the workflow will set GitHub restrictions (Set restrictions step), if not, then the default restrictions are set (Set default restrictions step).

  1. Set default restrictions is a Data storage connector step that is storing a default value '' under the specified 'Key' restrictions using the 'Set Value' operation.

This step sets a default value when a field restriction value is not available and, the result for the Boolean connector in the Has field restrictions? step is FALSE.

  1. Set restrictions is a Data storage connector step that is storing restrictions ($.steps.github-1.restrictions) value under under the specified 'Key' restrictions using the 'Set Value' operation.

This restriction field is set, when the result for the Boolean connector in the Has field restrictions? step is TRUE.

  1. Get restrictions is again a Data storage connector step to get the values set under the 'Key' restrictions using the 'Get Value' operation.

  1. Has branch protection is again a Google Sheets step like a No branch protection step. Again, your input will vary depending on the required spreadsheet content. In this step, along with all the fields included in the No branch protection step, we have included the following additional fields:

The additional fields will grab the protection information from the Get branch protection step or a Data Storage connector. Before you add the data to the Google Sheets connector, you may want to enter a few extra steps to make the data readable using the Helper connectors.

INTERPOLATION: When you wish to include JSON generated data within another input/output result, use our Interpolation method as described here.

All Operations

Latest version:

2.3

Add/update team membership

Adds an organization member to a team. An authenticated organization owner or team maintainer can add organization members to a team. If the user is already a member of the team, this endpoint will update the role of the team member's role. To update the membership of a team member, the authenticated user must be an organization owner or a team maintainer.

Compare commits

Compares two commits in a GitHub repository.

Create a release

Creates a release on a GitHub repository.

Create a status

Creates a status on a GitHub ref.

Create deploy key

Creates a deploy key for a specified repository.

Create issue

Creates an issue on a GitHub repository.

Create repository

Create a new repository.

Delete deploy key

Deletes a specified deploy key.

Delete repository

Delete a GitHub repository.

Get a single reference

Retrieves a single reference from your Git database.

Get branch

Retrieves the branch of a GitHub repository.

Get branch protection

Retrieves the GitHub branch protection rules of a branch on a repository.

Get commit

Get a commit in a GitHub repository.

Get deploy key

Retrieves information for a specified deploy key.

Get issue

Retrieves an issue of a GitHub repository by its number.

Get repository

Get details about a GitHub repository.

Get team

Retrieves information for a team using the team‘s name.

Get the latest published release

Retrieves the latest published release of a GitHub repository.

Get user

Retrieves information on a specified user.

List branches

Lists the branches of a GitHub repository.

List collaborators

Lists all collaborators for the specified repository.

List deploy keys

Lists the deploy keys for a specified repository.

List deploy keys DDL

List issues

Lists all issues assigned to the authenticated user.

List languages

Lists the languages of a GitHub repository.

List matching references

Lists matching GitHub references.

List organization issues

Lists all issues for a given organization that is assigned to your GitHub account.

List organization members

Lists members of an organization.

List organization repositories

List an organization's GitHub repositories.

List organization teams

Lists all teams in an organization that are visible to the authenticated user.

List pull requests

Lists pull requests from a GitHub repository.

List repository commits

List the commits of a GitHub repository.

List repository contributors

List all of the contributors to a GitHub repository.

List repository forks

List all of the forks of a GitHub repository.

List repository issues

Lists issues of a GitHub repository.

List repository teams

Lists the teams of a GitHub repository.

List tags

Lists the tags of a GitHub repository.

List team members

Lists members of a team.

List user issues

Lists all issues across owned and member repositories assigned to the authenticated user.

List user organizations DDL

List user repositories

Lists a user GitHub repositories.

List user repositories DDL

List your repositories

Lists your GitHub repositories.

Raw HTTP request (advanced)

Perform a raw HTTP request with some pre-configuration and processing by the connector, such as authentication.

Remove all branch protections

Removes all branch protections from a GitHub branch.

Update branch protection

Updates the GitHub branch protection rules of a branch on a repository.

Update issue

Updates an issue on a GitHub repository.

Update pull request

Updates a GitHub pull request.

Create organization repository

Create a new repository for an organization

Get a single pull request

Retrieves a pull request from a GitHub repository.

List organization teams DDL

List user organization IDs DDL

Update repository

Update a repository