GitHub vendor logo

Vendor

GitHub

Product

Method

REST

Category

CI/CD

Project Type

Workflow Project


View Repository
Workflow

GitHub - Modular Automations

Overview

The integration of Itential and GitHub enables network teams to utilize GitHub's REST API to build automations that can include common tasks for version control of assets. This is a library of related automations that can be used as modular components in your own larger, end-to-end workflows.

Workflows

NameOverview
Create Pull Request - GitHub - RESTCreate a pull request to propose changes to a project repository in GitHub
Commit File - GitHub - RESTCommit a file in GitHub
Create Branch - GitHub - RESTCreate a branch in GitHub
Get File - GitHub - RESTGet the contents of a file in a repository
Create Repository - GitHub - RESTCreate a new repository for the authenticated user

For further technical details on how to install and use this Workflow Project, please click the Technical Documentation tab.

Table of Contents

Getting Started

This section is helpful for deployments as it provides you with pertinent information on prerequisites and properties.

Helpful Background Information

Workflows often include logic that varies from business to business. As a result, we often find that our Workflow Projects are more useful as modular components that can be incorporated into a larger process. In addition, they often can add value as a learning tool on how we integrate with other systems and how we do things within the Itential Automation Platform.

While these can be utilized, you may find more value in using them as a starting point to build around.

Prerequisites

Itential Workflow Projects are built and tested on particular versions of IAP. In addition, Workflow Projects are often dependent on external systems and as such, these Workflow Projects will have dependencies on these other systems. This version of GitHub - REST has been tested with:

  • IAP 2023.2

External Dependencies

NameOS VersionAPI Version
GitHub2022-11-28

Adapters

NameVersionConfiguration Notes
adapter-github0.6.1

How to Install

To install the Workflow Project:

  • Verify you are running a supported version of the Itential Automation Platform (IAP) as listed above in the Supported IAP Versions section in order to install the Example Project.
  • Import the Example Project in Admin Essentials.

Testing

Cypress is generally used to test all Itential Example Projects. While Cypress is an opensource tool, at Itential we have internal libraries that have been built around Cypress to allow us to test with a deployed IAP.

When certifying our Example Projects for a release of IAP we run these tests against the particular version of IAP and create a release branch in GitLab. If you do not see the Example Project available in your version of IAP please contact Itential.

While Itential tests this Example Project and its capabilities, it is often the case the customer environments offer their own unique circumstances. Therefore, it is our recommendation that you deploy this Example Project into a development/testing environment in which you can test the Example Project.

Using this Workflow Project

Workflow Projects contain 1 or more workflows. Each of these workflows have different inputs and outputs.

Commit File - GitHub - REST

Commit a file in GitHub

Capabilities include:

  • The workflow is used to commit a file in GitHub to track changes to a project's codebase

Entry Point IAP Component

The primary IAP component to run Commit File - GitHub - REST is listed below:

IAP Component NameIAP Component Type
Commit File - GitHub - RESTWorkflow

Inputs

The following table lists the inputs for Commit File - GitHub - REST:

NameTypeRequiredDescriptionExample Value
repoOwnerstringyesThe account owner of the repository. The name is not case sensitive
user1
repoNamestringyesThe name of the repository without the .git extension. The name is not case sensitive
test-repo
filePathstringyesThe path to the file including the file name. For files in the root directory, this is just a file name
README.md
branchNamestringyesThe name of the branch
main
commitMessagestringyesThe commit message
Update README
fileContentstringyesThe new file content, using Base64 encoding
# test-repo
This is draft readme
adapterIdstringyesThe GitHub adapter instance to use in the workflow
github

Outputs

The following table lists the outputs for Commit File - GitHub - REST:

NameTypeDescriptionExample Value
fileResultobjectResult of successfully getting the file content
{
  "icode": "AD.200",
  "response": {
    "pathParam": "README.md",
    "pathParamQuery": "README.md",
    "content": "# test-repo This is draft readme",
    "name": "README.md",
    "sha": "4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
    "size": 33,
    "url": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=main",
    "html_url": "https://github.com/user1/test-repo/blob/main/README.md",
    "git_url": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
    "download_url": "https://raw.githubusercontent.com/user1/test-repo/main/README.md?token=token",
    "type": "file",
    "encoding": "base64",
    "_links": {
      "self": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=main",
      "git": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
      "html": "https://github.com/user1/test-repo/blob/main/README.md"
    }
  }
}
commitResultobjectResult of successfully commiting the file
{
  "icode": "AD.200",
  "response": {
    "commit": {
      "sha": "40d4e44271bb5be4ad345f842a8a8dbf6fe2361c",
      "node_id": "C_kwDOLJpowdoAKDQwZDRlNDQyNzFiYjViZTRhZDM0NWY4NDJhOGE4ZGJmNmZlMjM2MWM",
      "url": "https://api.github.com/repos/user1/test-repo/git/commits/40d4e44271bb5be4ad345f842a8a8dbf6fe2361c",
      "html_url": "https://github.com/user1/test-repo/commit/40d4e44271bb5be4ad345f842a8a8dbf6fe2361c",
      "author": {
        "name": "user1",
        "email": "56144843+user1@users.noreply.github.com",
        "date": "2024-01-25T18:29:44Z"
      },
      "committer": {
        "name": "user1",
        "email": "56144843+user1@users.noreply.github.com",
        "date": "2024-01-25T18:29:44Z"
      },
      "tree": {
        "sha": "250806578bfd755d3572a1a3ff520023ab1d243e",
        "url": "https://api.github.com/repos/user1/test-repo/git/trees/250806578bfd755d3572a1a3ff520023ab1d243e"
      },
      "message": "Update README",
      "parents": [
        {
          "sha": "d862756b04225012feea6608fbe6fdecf515a432",
          "url": "https://api.github.com/repos/user1/test-repo/git/commits/d862756b04225012feea6608fbe6fdecf515a432",
          "html_url": "https://github.com/user1/test-repo/commit/d862756b04225012feea6608fbe6fdecf515a432"
        }
      ],
      "verification": {
        "verified": false,
        "reason": "unsigned",
        "signature": null,
        "payload": null
      }
    }
  }
}
githubErrorobjectResult if failure getting the file contents or commiting the file
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "github-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "response": {
        "message": "Not Found",
        "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
      },
      "redirects": 0,
      "tripTime": "1594ms"
    }
  },
  "response": {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
  }
}

Query Output

The following items show how to query successful results from the output of Commit File - GitHub - REST:

New Commit SHA

commitResult.response.commit.sha

The following items show how to query failure results from the output of Commit File - GitHub - REST:

Error Response Message

githubError.response.message

Example Inputs and Outputs

Example 1

Input:

{
  "repoOwner": "user1",
  "repoName": "test-repo",
  "filePath": "README.md",
  "adapterId": "github",
  "branchName": "main",
  "commitMessage": "Update README",
  "fileContent": "# test-repo\
This is draft readme"
} 

Output:

{
  "fileResult": {
    "icode": "AD.200",
    "response": {
      "pathParam": "README.md",
      "pathParamQuery": "README.md",
      "content": "# test-repo\
This is draft readme",
      "name": "README.md",
      "sha": "4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
      "size": 33,
      "url": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=main",
      "html_url": "https://github.com/user1/test-repo/blob/main/README.md",
      "git_url": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
      "download_url": "https://raw.githubusercontent.com/user1/test-repo/main/README.md?token=token",
      "type": "file",
      "encoding": "base64",
      "_links": {
        "self": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=main",
        "git": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
        "html": "https://github.com/user1/test-repo/blob/main/README.md"
      }
    }
  },
  "commitResult": {
    "icode": "AD.200",
    "response": {
      "commit": {
        "sha": "40d4e44271bb5be4ad345f842a8a8dbf6fe2361c",
        "node_id": "C_kwDOLJpowdoAKDQwZDRlNDQyNzFiYjViZTRhZDM0NWY4NDJhOGE4ZGJmNmZlMjM2MWM",
        "url": "https://api.github.com/repos/user1/test-repo/git/commits/40d4e44271bb5be4ad345f842a8a8dbf6fe2361c",
        "html_url": "https://github.com/user1/test-repo/commit/40d4e44271bb5be4ad345f842a8a8dbf6fe2361c",
        "author": {
          "name": "user1",
          "email": "56144843+user1@users.noreply.github.com",
          "date": "2024-01-25T18:29:44Z"
        },
        "committer": {
          "name": "user1",
          "email": "56144843+user1@users.noreply.github.com",
          "date": "2024-01-25T18:29:44Z"
        },
        "tree": {
          "sha": "250806578bfd755d3572a1a3ff520023ab1d243e",
          "url": "https://api.github.com/repos/user1/test-repo/git/trees/250806578bfd755d3572a1a3ff520023ab1d243e"
        },
        "message": "Update README",
        "parents": [
          {
            "sha": "d862756b04225012feea6608fbe6fdecf515a432",
            "url": "https://api.github.com/repos/user1/test-repo/git/commits/d862756b04225012feea6608fbe6fdecf515a432",
            "html_url": "https://github.com/user1/test-repo/commit/d862756b04225012feea6608fbe6fdecf515a432"
          }
        ],
        "verification": {
          "verified": false,
          "reason": "unsigned",
          "signature": null,
          "payload": null
        }
      }
    }
  }
} 
Example 2

Input:

{
  "repoOwner": "user1",
  "repoName": "test-repo",
  "filePath": "doc/readme.md",
  "adapterId": "github",
  "branchName": "main",
  "commitMessage": "Update README",
  "fileContent": "# test-repo\
This is draft readme"
} 

Output:

{
  "fileResult": {
    "icode": "AD.500",
    "IAPerror": {
      "origin": "github-connectorRest-handleEndResponse",
      "displayString": "Error 404 received on request",
      "recommendation": "Verify the request is accurate via debug logs and postman",
      "code": 404,
      "raw_response": {
        "status": "success",
        "code": 404,
        "response": "{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest/repos/contents#get-repository-content\"}",
        "redirects": 0,
        "tripTime": "1594ms"
      }
    },
    "response": {
      "message": "Not Found",
      "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
    }
  },
  "githubError": {
    "icode": "AD.500",
    "IAPerror": {
      "origin": "github-connectorRest-handleEndResponse",
      "displayString": "Error 404 received on request",
      "recommendation": "Verify the request is accurate via debug logs and postman",
      "code": 404,
      "raw_response": {
        "status": "success",
        "code": 404,
        "response": {
          "message": "Not Found",
          "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
        },
        "redirects": 0,
        "tripTime": "1594ms"
      }
    },
    "response": {
      "message": "Not Found",
      "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
    }
  },
  "commitResult": {
    "icode": "AD.201",
    "response": {
      "commit": {
        "sha": "9094b5364efd5a7ef0c0624cc87d12c66fa4747f",
        "node_id": "C_kwDOLJpowdoAKDkwOTRiNTM2NGVmZDVhN2VmMGMwNjI0Y2M4N2QxMmM2NmZhNDc0N2Y",
        "url": "https://api.github.com/repos/user1/test-repo/git/commits/9094b5364efd5a7ef0c0624cc87d12c66fa4747f",
        "html_url": "https://github.com/user1/test-repo/commit/9094b5364efd5a7ef0c0624cc87d12c66fa4747f",
        "author": {
          "name": "user1",
          "email": "56144843+user1@users.noreply.github.com",
          "date": "2024-01-26T18:41:51Z"
        },
        "committer": {
          "name": "user1",
          "email": "56144843+user1@users.noreply.github.com",
          "date": "2024-01-26T18:41:51Z"
        },
        "tree": {
          "sha": "0975fb9a62776166c135f0210c4286a33e6bd8f1",
          "url": "https://api.github.com/repos/user1/test-repo/git/trees/0975fb9a62776166c135f0210c4286a33e6bd8f1"
        },
        "message": "Update README",
        "parents": [
          {
            "sha": "3321216d4cb2ed6d0ddfbd99cabec3e1b38e4083",
            "url": "https://api.github.com/repos/user1/test-repo/git/commits/3321216d4cb2ed6d0ddfbd99cabec3e1b38e4083",
            "html_url": "https://github.com/user1/test-repo/commit/3321216d4cb2ed6d0ddfbd99cabec3e1b38e4083"
          }
        ],
        "verification": {
          "verified": false,
          "reason": "unsigned",
          "signature": null,
          "payload": null
        }
      }
    }
  }
} 

API Links

API NameAPI Documentation LinkAPI Link Visibility
Using GitHub REST APIhttps://docs.github.com/en/rest?apiVersion=2022-11-28Public

Create Branch - GitHub - REST

Create a branch in GitHub

Capabilities include:

  • The workflow is used to create a branch in GitHub

Entry Point IAP Component

The primary IAP component to run Create Branch - GitHub - REST is listed below:

IAP Component NameIAP Component Type
Create Branch - GitHub - RESTWorkflow

Inputs

The following table lists the inputs for Create Branch - GitHub - REST:

NameTypeRequiredDescriptionExample Value
branchNamestringyesThe name of the branch to be created
patch/issue-01
ownerstringyesThe account owner of the repository. The name is not case sensitive
user1
repoNamestringyesThe name of the repository without the .git extension. The name is not case sensitive
test-repo
refBranchNamestringyesThe name of the ref branch from which the new branch is created
main
adapterIdstringyesThe GitHub adapter instance to use in the workflow
github

Outputs

The following table lists the outputs for Create Branch - GitHub - REST:

NameTypeDescriptionExample Value
branchResultobjectResult of successfully getting the branch (in case branch is already created) or creating a new branch
{
  "icode": "AD.201",
  "response": {
    "ref": "refs/heads/patch/issue-01",
    "node_id": "REF_kwDOLJpowblyZWZzL2hlYWRzL3BhdGNoL2lzc3VlLTAx",
    "url": "https://api.github.com/repos/user1/test-repo/git/refs/heads/patch/issue-01",
    "object": {
      "sha": "6107454973e77e3e09a62a946e185720eed10c60",
      "type": "commit",
      "url": "https://api.github.com/repos/user1/test-repo/git/commits/6107454973e77e3e09a62a946e185720eed10c60"
    }
  }
}
githubErrorobjectResult if failure getting the branch, ref branch or creating the reference
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "github-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "response": {
        "message": "Branch not found",
        "documentation_url": "https://docs.github.com/rest/branches/branches#get-a-branch"
      },
      "redirects": 0,
      "tripTime": "1460ms"
    }
  },
  "response": {
    "message": "Branch not found",
    "documentation_url": "https://docs.github.com/rest/branches/branches#get-a-branch"
  }
}

Query Output

The following items show how to query successful results from the output of Create Branch - GitHub - REST:

Created Branch

branchResult.response.ref

The following items show how to query failure results from the output of Create Branch - GitHub - REST:

Error Response Message

githubError.response.message

Example Inputs and Outputs

Example 1

Input:

{
  "branchName": "patch/issue-01",
  "owner": "user1",
  "repoName": "test-repo",
  "adapterId": "github",
  "refBranchName": "main"
} 

Output:

{
  "branchResult": {
    "icode": "AD.201",
    "response": {
      "ref": "refs/heads/patch/issue-01",
      "node_id": "REF_kwDOLJpowblyZWZzL2hlYWRzL3BhdGNoL2lzc3VlLTAx",
      "url": "https://api.github.com/repos/user1/test-repo/git/refs/heads/patch/issue-01",
      "object": {
        "sha": "6107454973e77e3e09a62a946e185720eed10c60",
        "type": "commit",
        "url": "https://api.github.com/repos/user1/test-repo/git/commits/6107454973e77e3e09a62a946e185720eed10c60"
      }
    }
  },
  "githubError": {
    "icode": "AD.500",
    "IAPerror": {
      "origin": "github-connectorRest-handleEndResponse",
      "displayString": "Error 404 received on request",
      "recommendation": "Verify the request is accurate via debug logs and postman",
      "code": 404,
      "raw_response": {
        "status": "success",
        "code": 404,
        "response": {
          "message": "Branch not found",
          "documentation_url": "https://docs.github.com/rest/branches/branches#get-a-branch"
        },
        "redirects": 0,
        "tripTime": "1460ms"
      }
    },
    "response": {
      "message": "Branch not found",
      "documentation_url": "https://docs.github.com/rest/branches/branches#get-a-branch"
    }
  }
} 

API Links

API NameAPI Documentation LinkAPI Link Visibility
Using GitHub REST APIhttps://docs.github.com/en/rest?apiVersion=2022-11-28Public

Create Pull Request - GitHub - REST

Create a pull request to propose changes to a project repository in GitHub

Capabilities include:

  • The workflow is used to create a pull request to propose changes to a project repository in GitHub

Entry Point IAP Component

The primary IAP component to run Create Pull Request - GitHub - REST is listed below:

IAP Component NameIAP Component Type
Create Pull Request - GitHub - RESTWorkflow

Inputs

The following table lists the inputs for Create Pull Request - GitHub - REST:

NameTypeRequiredDescriptionExample Value
repoOwnerstringyesThe account owner of the repository. The name is not case sensitive
user1
repoNamestringyesThe name of the repository without the .git extension. The name is not case sensitive
test-repo
prTitlestringyesThe title of the new pull request
Resolve Alignment Issue
sourceBranchstringyesThe name of the branch where your changes are implemented
patch/issue-01
targetBranchstringyesThe name of the branch you want the changes pulled into
main
adapterIdstringyesThe GitHub adapter instance to use in the workflow
github

Outputs

The following table lists the outputs for Create Pull Request - GitHub - REST:

NameTypeDescriptionExample Value
pullRequestResultobjectResult of successfully creating pull reqeust
{
  "icode": "AD.201",
  "response": {
    "url": "https://api.github.com/repos/user1/test-repo/pulls/1",
    "id": 1696285610,
    "node_id": "PR_kwDOLJpowc5lG0Oq",
    "html_url": "https://github.com/user1/test-repo/pull/1",
    "diff_url": "https://github.com/user1/test-repo/pull/1.diff",
    "patch_url": "https://github.com/user1/test-repo/pull/1.patch",
    "issue_url": "https://api.github.com/repos/user1/test-repo/issues/1",
    "number": 1,
    "state": "open",
    "locked": false,
    "title": "Resolve Alignment Issue",
    "user": {},
    "body": null,
    "created_at": "2024-01-25T21:06:47Z",
    "updated_at": "2024-01-25T21:06:47Z",
    "closed_at": null,
    "merged_at": null,
    "merge_commit_sha": null,
    "assignee": null,
    "assignees": [],
    "requested_reviewers": [],
    "requested_teams": [],
    "labels": [],
    "milestone": null,
    "draft": false,
    "commits_url": "https://api.github.com/repos/user1/test-repo/pulls/1/commits",
    "review_comments_url": "https://api.github.com/repos/user1/test-repo/pulls/1/comments",
    "review_comment_url": "https://api.github.com/repos/user1/test-repo/pulls/comments{/number}",
    "comments_url": "https://api.github.com/repos/user1/test-repo/issues/1/comments",
    "statuses_url": "https://api.github.com/repos/user1/test-repo/statuses/6bbcc0d7224725f0e3b97b8a934c959203629e36",
    "head": {
      "label": "user1:patch/issue-01",
      "ref": "patch/issue-01",
      "sha": "6bbcc0d7224725f0e3b97b8a934c959203629e36",
      "user": {},
      "repo": {}
    },
    "base": {
      "label": "user1:main",
      "ref": "main",
      "sha": "6107454973e77e3e09a62a946e185720eed10c60",
      "user": {},
      "repo": {}
    },
    "_links": {
      "self": {
        "href": "https://api.github.com/repos/user1/test-repo/pulls/1"
      },
      "html": {
        "href": "https://github.com/user1/test-repo/pull/1"
      },
      "issue": {
        "href": "https://api.github.com/repos/user1/test-repo/issues/1"
      },
      "comments": {
        "href": "https://api.github.com/repos/user1/test-repo/issues/1/comments"
      },
      "review_comments": {
        "href": "https://api.github.com/repos/user1/test-repo/pulls/1/comments"
      },
      "review_comment": {
        "href": "https://api.github.com/repos/user1/test-repo/pulls/comments{/number}"
      },
      "commits": {
        "href": "https://api.github.com/repos/user1/test-repo/pulls/1/commits"
      },
      "statuses": {
        "href": "https://api.github.com/repos/user1/test-repo/statuses/6bbcc0d7224725f0e3b97b8a934c959203629e36"
      }
    },
    "author_association": "OWNER",
    "auto_merge": null,
    "active_lock_reason": null,
    "merged": false,
    "mergeable": null,
    "rebaseable": null,
    "mergeable_state": "unknown",
    "merged_by": null,
    "comments": 0,
    "review_comments": 0,
    "maintainer_can_modify": false,
    "commits": 1,
    "additions": 1,
    "deletions": 1,
    "changed_files": 1
  }
}
githubErrorobjectResult if failure creating the pull request
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "github-connectorRest-handleEndResponse",
    "displayString": "Error 422 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 422,
    "raw_response": {
      "status": "success",
      "code": 422,
      "response": {
        "message": "Validation Failed",
        "errors": [
          {
            "resource": "PullRequest",
            "field": "head",
            "code": "invalid"
          }
        ],
        "documentation_url": "https://docs.github.com/rest/pulls/pulls#create-a-pull-request"
      },
      "redirects": 0,
      "tripTime": "1429ms"
    }
  },
  "response": {
    "message": "Validation Failed",
    "errors": [
      {
        "resource": "PullRequest",
        "field": "head",
        "code": "invalid"
      }
    ],
    "documentation_url": "https://docs.github.com/rest/pulls/pulls#create-a-pull-request"
  }
}

Query Output

The following items show how to query successful results from the output of Create Pull Request - GitHub - REST:

Pull Request Number

pullRequestResult.response.number

The following items show how to query failure results from the output of Create Pull Request - GitHub - REST:

Error Response Message

githubError.response.message

Example Inputs and Outputs

Example 1

Input:

{
  "repoOwner": "user1",
  "repoName": "test-repo",
  "adapterId": "github",
  "prTitle": "Resolve Alignment Issue",
  "sourceBranch": "patch/issue-01",
  "targetBranch": "main"
} 

Output:

{
  "pullRequestResult": {
    "icode": "AD.201",
    "response": {
      "url": "https://api.github.com/repos/user1/test-repo/pulls/1",
      "id": 1696285610,
      "node_id": "PR_kwDOLJpowc5lG0Oq",
      "html_url": "https://github.com/user1/test-repo/pull/1",
      "diff_url": "https://github.com/user1/test-repo/pull/1.diff",
      "patch_url": "https://github.com/user1/test-repo/pull/1.patch",
      "issue_url": "https://api.github.com/repos/user1/test-repo/issues/1",
      "number": 1,
      "state": "open",
      "locked": false,
      "title": "Resolve Alignment Issue",
      "user": {},
      "body": null,
      "created_at": "2024-01-25T21:06:47Z",
      "updated_at": "2024-01-25T21:06:47Z",
      "closed_at": null,
      "merged_at": null,
      "merge_commit_sha": null,
      "assignee": null,
      "assignees": [],
      "requested_reviewers": [],
      "requested_teams": [],
      "labels": [],
      "milestone": null,
      "draft": false,
      "commits_url": "https://api.github.com/repos/user1/test-repo/pulls/1/commits",
      "review_comments_url": "https://api.github.com/repos/user1/test-repo/pulls/1/comments",
      "review_comment_url": "https://api.github.com/repos/user1/test-repo/pulls/comments{/number}",
      "comments_url": "https://api.github.com/repos/user1/test-repo/issues/1/comments",
      "statuses_url": "https://api.github.com/repos/user1/test-repo/statuses/6bbcc0d7224725f0e3b97b8a934c959203629e36",
      "head": {
        "label": "user1:patch/issue-01",
        "ref": "patch/issue-01",
        "sha": "6bbcc0d7224725f0e3b97b8a934c959203629e36",
        "user": {},
        "repo": {}
      },
      "base": {
        "label": "user1:main",
        "ref": "main",
        "sha": "6107454973e77e3e09a62a946e185720eed10c60",
        "user": {},
        "repo": {}
      },
      "_links": {
        "self": {
          "href": "https://api.github.com/repos/user1/test-repo/pulls/1"
        },
        "html": {
          "href": "https://github.com/user1/test-repo/pull/1"
        },
        "issue": {
          "href": "https://api.github.com/repos/user1/test-repo/issues/1"
        },
        "comments": {
          "href": "https://api.github.com/repos/user1/test-repo/issues/1/comments"
        },
        "review_comments": {
          "href": "https://api.github.com/repos/user1/test-repo/pulls/1/comments"
        },
        "review_comment": {
          "href": "https://api.github.com/repos/user1/test-repo/pulls/comments{/number}"
        },
        "commits": {
          "href": "https://api.github.com/repos/user1/test-repo/pulls/1/commits"
        },
        "statuses": {
          "href": "https://api.github.com/repos/user1/test-repo/statuses/6bbcc0d7224725f0e3b97b8a934c959203629e36"
        }
      },
      "author_association": "OWNER",
      "auto_merge": null,
      "active_lock_reason": null,
      "merged": false,
      "mergeable": null,
      "rebaseable": null,
      "mergeable_state": "unknown",
      "merged_by": null,
      "comments": 0,
      "review_comments": 0,
      "maintainer_can_modify": false,
      "commits": 1,
      "additions": 1,
      "deletions": 1,
      "changed_files": 1
    }
  }
} 
Example 2

Input:

{
  "repoOwner": "user1",
  "repoName": "test-repo",
  "adapterId": "github",
  "prTitle": "Resolve Alignment Issue",
  "sourceBranch": "patch/issue-02",
  "targetBranch": "main"
} 

Output:

{
  "githubError": {
    "icode": "AD.500",
    "IAPerror": {
      "origin": "github-connectorRest-handleEndResponse",
      "displayString": "Error 422 received on request",
      "recommendation": "Verify the request is accurate via debug logs and postman",
      "code": 422,
      "raw_response": {
        "status": "success",
        "code": 422,
        "response": {
          "message": "Validation Failed",
          "errors": [
            {
              "resource": "PullRequest",
              "field": "head",
              "code": "invalid"
            }
          ],
          "documentation_url": "https://docs.github.com/rest/pulls/pulls#create-a-pull-request"
        },
        "redirects": 0,
        "tripTime": "1429ms"
      }
    },
    "response": {
      "message": "Validation Failed",
      "errors": [
        {
          "resource": "PullRequest",
          "field": "head",
          "code": "invalid"
        }
      ],
      "documentation_url": "https://docs.github.com/rest/pulls/pulls#create-a-pull-request"
    }
  },
  "pullRequestResult": null
} 

API Links

API NameAPI Documentation LinkAPI Link Visibility
Using GitHub REST APIhttps://docs.github.com/en/rest?apiVersion=2022-11-28Public

Create Repository - GitHub - REST

Create a new repository for the authenticated user

Capabilities include:

  • The workflow is used to create a new repository for the authenticated user

Entry Point IAP Component

The primary IAP component to run Create Repository - GitHub - REST is listed below:

IAP Component NameIAP Component Type
Create Repository - GitHub - RESTWorkflow

Inputs

The following table lists the inputs for Create Repository - GitHub - REST:

NameTypeRequiredDescriptionExample Value
ownerstringyesThe account owner of the repository. The name is not case sensitive
user1
repoNamestringyesThe name of the repository without the .git extension. The name is not case sensitive
my-website
repoDescriptionstringnoA short description of the repository
My first website project
adapterIdstringyesThe GitHub adapter instance to use in the workflow
github

Outputs

The following table lists the outputs for Create Repository - GitHub - REST:

NameTypeDescriptionExample Value
repoResultobjectResult of successfully creating a new repo
{
  "icode": "AD.201",
  "response": {
    "id": 748372557,
    "node_id": "R_kgDOLJtCTQ",
    "name": "my-website",
    "full_name": "user1/my-website",
    "private": false,
    "owner": {
      "login": "user1",
      "id": 56144843,
      "node_id": "MDQ6VXNlcjU2MTQ0ODQz",
      "avatar_url": "https://avatars.githubusercontent.com/u/56144843?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/user1",
      "html_url": "https://github.com/user1",
      "followers_url": "https://api.github.com/users/user1/followers",
      "following_url": "https://api.github.com/users/user1/following{/other_user}",
      "gists_url": "https://api.github.com/users/user1/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/user1/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/user1/subscriptions",
      "organizations_url": "https://api.github.com/users/user1/orgs",
      "repos_url": "https://api.github.com/users/user1/repos",
      "events_url": "https://api.github.com/users/user1/events{/privacy}",
      "received_events_url": "https://api.github.com/users/user1/received_events",
      "type": "User",
      "site_admin": false
    },
    "html_url": "https://github.com/user1/my-website",
    "description": "A simple repo for my first website project",
    "fork": false,
    "url": "https://api.github.com/repos/user1/my-website",
    "forks_url": "https://api.github.com/repos/user1/my-website/forks",
    "keys_url": "https://api.github.com/repos/user1/my-website/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/user1/my-website/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/user1/my-website/teams",
    "hooks_url": "https://api.github.com/repos/user1/my-website/hooks",
    "issue_events_url": "https://api.github.com/repos/user1/my-website/issues/events{/number}",
    "events_url": "https://api.github.com/repos/user1/my-website/events",
    "assignees_url": "https://api.github.com/repos/user1/my-website/assignees{/user}",
    "branches_url": "https://api.github.com/repos/user1/my-website/branches{/branch}",
    "tags_url": "https://api.github.com/repos/user1/my-website/tags",
    "blobs_url": "https://api.github.com/repos/user1/my-website/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/user1/my-website/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/user1/my-website/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/user1/my-website/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/user1/my-website/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/user1/my-website/languages",
    "stargazers_url": "https://api.github.com/repos/user1/my-website/stargazers",
    "contributors_url": "https://api.github.com/repos/user1/my-website/contributors",
    "subscribers_url": "https://api.github.com/repos/user1/my-website/subscribers",
    "subscription_url": "https://api.github.com/repos/user1/my-website/subscription",
    "commits_url": "https://api.github.com/repos/user1/my-website/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/user1/my-website/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/user1/my-website/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/user1/my-website/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/user1/my-website/contents/{+path}",
    "compare_url": "https://api.github.com/repos/user1/my-website/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/user1/my-website/merges",
    "archive_url": "https://api.github.com/repos/user1/my-website/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/user1/my-website/downloads",
    "issues_url": "https://api.github.com/repos/user1/my-website/issues{/number}",
    "pulls_url": "https://api.github.com/repos/user1/my-website/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/user1/my-website/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/user1/my-website/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/user1/my-website/labels{/name}",
    "releases_url": "https://api.github.com/repos/user1/my-website/releases{/id}",
    "deployments_url": "https://api.github.com/repos/user1/my-website/deployments",
    "created_at": "2024-01-25T20:44:40Z",
    "updated_at": "2024-01-25T20:44:40Z",
    "pushed_at": "2024-01-25T20:44:40Z",
    "git_url": "git://github.com/user1/my-website.git",
    "ssh_url": "git@github.com:user1/my-website.git",
    "clone_url": "https://github.com/user1/my-website.git",
    "svn_url": "https://github.com/user1/my-website",
    "homepage": null,
    "size": 0,
    "stargazers_count": 0,
    "watchers_count": 0,
    "language": null,
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "has_discussions": false,
    "forks_count": 0,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 0,
    "license": null,
    "allow_forking": true,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [],
    "visibility": "public",
    "forks": 0,
    "open_issues": 0,
    "watchers": 0,
    "default_branch": "main",
    "permissions": {
      "admin": true,
      "maintain": true,
      "push": true,
      "triage": true,
      "pull": true
    },
    "allow_squash_merge": true,
    "allow_merge_commit": true,
    "allow_rebase_merge": true,
    "allow_auto_merge": false,
    "delete_branch_on_merge": false,
    "allow_update_branch": false,
    "use_squash_pr_title_as_default": false,
    "squash_merge_commit_message": "COMMIT_MESSAGES",
    "squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
    "merge_commit_message": "PR_TITLE",
    "merge_commit_title": "MERGE_MESSAGE",
    "network_count": 0,
    "subscribers_count": 0
  }
}
githubErrorobjectResult if failure getting the repo or creating a new repo
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "github-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "response": {
        "message": "Not Found",
        "documentation_url": "https://docs.github.com/rest/repos/repos#get-a-repository"
      },
      "redirects": 0,
      "tripTime": "1226ms"
    }
  },
  "response": {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest/repos/repos#get-a-repository"
  }
}

Query Output

The following items show how to query successful results from the output of Create Repository - GitHub - REST:

Repo Full Name

repoResult.response.full_name

The following items show how to query failure results from the output of Create Repository - GitHub - REST:

Error Response Message

githubError.response.message

Example Inputs and Outputs

Example 1

Input:

{
  "owner": "user1",
  "repoName": "my-website",
  "adapterId": "github",
  "repoDescription": "A simple repo for my first website project"
} 

Output:

{
  "githubError": {
    "icode": "AD.500",
    "IAPerror": {
      "origin": "github-connectorRest-handleEndResponse",
      "displayString": "Error 404 received on request",
      "recommendation": "Verify the request is accurate via debug logs and postman",
      "code": 404,
      "raw_response": {
        "status": "success",
        "code": 404,
        "response": {
          "message": "Not Found",
          "documentation_url": "https://docs.github.com/rest/repos/repos#get-a-repository"
        },
        "redirects": 0,
        "tripTime": "1226ms"
      }
    },
    "response": {
      "message": "Not Found",
      "documentation_url": "https://docs.github.com/rest/repos/repos#get-a-repository"
    }
  },
  "repoResult": {
    "icode": "AD.201",
    "response": {
      "id": 748372557,
      "node_id": "R_kgDOLJtCTQ",
      "name": "my-website",
      "full_name": "user1/my-website",
      "private": false,
      "owner": {
        "login": "user1",
        "id": 56144843,
        "node_id": "MDQ6VXNlcjU2MTQ0ODQz",
        "avatar_url": "https://avatars.githubusercontent.com/u/56144843?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/user1",
        "html_url": "https://github.com/user1",
        "followers_url": "https://api.github.com/users/user1/followers",
        "following_url": "https://api.github.com/users/user1/following{/other_user}",
        "gists_url": "https://api.github.com/users/user1/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/user1/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/user1/subscriptions",
        "organizations_url": "https://api.github.com/users/user1/orgs",
        "repos_url": "https://api.github.com/users/user1/repos",
        "events_url": "https://api.github.com/users/user1/events{/privacy}",
        "received_events_url": "https://api.github.com/users/user1/received_events",
        "type": "User",
        "site_admin": false
      },
      "html_url": "https://github.com/user1/my-website",
      "description": "A simple repo for my first website project",
      "fork": false,
      "url": "https://api.github.com/repos/user1/my-website",
      "forks_url": "https://api.github.com/repos/user1/my-website/forks",
      "keys_url": "https://api.github.com/repos/user1/my-website/keys{/key_id}",
      "collaborators_url": "https://api.github.com/repos/user1/my-website/collaborators{/collaborator}",
      "teams_url": "https://api.github.com/repos/user1/my-website/teams",
      "hooks_url": "https://api.github.com/repos/user1/my-website/hooks",
      "issue_events_url": "https://api.github.com/repos/user1/my-website/issues/events{/number}",
      "events_url": "https://api.github.com/repos/user1/my-website/events",
      "assignees_url": "https://api.github.com/repos/user1/my-website/assignees{/user}",
      "branches_url": "https://api.github.com/repos/user1/my-website/branches{/branch}",
      "tags_url": "https://api.github.com/repos/user1/my-website/tags",
      "blobs_url": "https://api.github.com/repos/user1/my-website/git/blobs{/sha}",
      "git_tags_url": "https://api.github.com/repos/user1/my-website/git/tags{/sha}",
      "git_refs_url": "https://api.github.com/repos/user1/my-website/git/refs{/sha}",
      "trees_url": "https://api.github.com/repos/user1/my-website/git/trees{/sha}",
      "statuses_url": "https://api.github.com/repos/user1/my-website/statuses/{sha}",
      "languages_url": "https://api.github.com/repos/user1/my-website/languages",
      "stargazers_url": "https://api.github.com/repos/user1/my-website/stargazers",
      "contributors_url": "https://api.github.com/repos/user1/my-website/contributors",
      "subscribers_url": "https://api.github.com/repos/user1/my-website/subscribers",
      "subscription_url": "https://api.github.com/repos/user1/my-website/subscription",
      "commits_url": "https://api.github.com/repos/user1/my-website/commits{/sha}",
      "git_commits_url": "https://api.github.com/repos/user1/my-website/git/commits{/sha}",
      "comments_url": "https://api.github.com/repos/user1/my-website/comments{/number}",
      "issue_comment_url": "https://api.github.com/repos/user1/my-website/issues/comments{/number}",
      "contents_url": "https://api.github.com/repos/user1/my-website/contents/{+path}",
      "compare_url": "https://api.github.com/repos/user1/my-website/compare/{base}...{head}",
      "merges_url": "https://api.github.com/repos/user1/my-website/merges",
      "archive_url": "https://api.github.com/repos/user1/my-website/{archive_format}{/ref}",
      "downloads_url": "https://api.github.com/repos/user1/my-website/downloads",
      "issues_url": "https://api.github.com/repos/user1/my-website/issues{/number}",
      "pulls_url": "https://api.github.com/repos/user1/my-website/pulls{/number}",
      "milestones_url": "https://api.github.com/repos/user1/my-website/milestones{/number}",
      "notifications_url": "https://api.github.com/repos/user1/my-website/notifications{?since,all,participating}",
      "labels_url": "https://api.github.com/repos/user1/my-website/labels{/name}",
      "releases_url": "https://api.github.com/repos/user1/my-website/releases{/id}",
      "deployments_url": "https://api.github.com/repos/user1/my-website/deployments",
      "created_at": "2024-01-25T20:44:40Z",
      "updated_at": "2024-01-25T20:44:40Z",
      "pushed_at": "2024-01-25T20:44:40Z",
      "git_url": "git://github.com/user1/my-website.git",
      "ssh_url": "git@github.com:user1/my-website.git",
      "clone_url": "https://github.com/user1/my-website.git",
      "svn_url": "https://github.com/user1/my-website",
      "homepage": null,
      "size": 0,
      "stargazers_count": 0,
      "watchers_count": 0,
      "language": null,
      "has_issues": true,
      "has_projects": true,
      "has_downloads": true,
      "has_wiki": true,
      "has_pages": false,
      "has_discussions": false,
      "forks_count": 0,
      "mirror_url": null,
      "archived": false,
      "disabled": false,
      "open_issues_count": 0,
      "license": null,
      "allow_forking": true,
      "is_template": false,
      "web_commit_signoff_required": false,
      "topics": [],
      "visibility": "public",
      "forks": 0,
      "open_issues": 0,
      "watchers": 0,
      "default_branch": "main",
      "permissions": {
        "admin": true,
        "maintain": true,
        "push": true,
        "triage": true,
        "pull": true
      },
      "allow_squash_merge": true,
      "allow_merge_commit": true,
      "allow_rebase_merge": true,
      "allow_auto_merge": false,
      "delete_branch_on_merge": false,
      "allow_update_branch": false,
      "use_squash_pr_title_as_default": false,
      "squash_merge_commit_message": "COMMIT_MESSAGES",
      "squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
      "merge_commit_message": "PR_TITLE",
      "merge_commit_title": "MERGE_MESSAGE",
      "network_count": 0,
      "subscribers_count": 0
    }
  }
} 
Example 2

Input:

{
  "owner": "user1",
  "repoName": "test-repo",
  "adapterId": "github",
  "repoDescription": "A simple repo for my first website project"
} 

Output:

{
  "repoResult": {
    "icode": "AD.200",
    "response": {
      "id": 748316865,
      "node_id": "R_kgDOLJpowQ",
      "name": "test-repo",
      "full_name": "user1/test-repo",
      "private": true,
      "owner": {
        "login": "user1",
        "id": 56144843,
        "node_id": "MDQ6VXNlcjU2MTQ0ODQz",
        "avatar_url": "https://avatars.githubusercontent.com/u/56144843?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/user1",
        "html_url": "https://github.com/user1",
        "followers_url": "https://api.github.com/users/user1/followers",
        "following_url": "https://api.github.com/users/user1/following{/other_user}",
        "gists_url": "https://api.github.com/users/user1/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/user1/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/user1/subscriptions",
        "organizations_url": "https://api.github.com/users/user1/orgs",
        "repos_url": "https://api.github.com/users/user1/repos",
        "events_url": "https://api.github.com/users/user1/events{/privacy}",
        "received_events_url": "https://api.github.com/users/user1/received_events",
        "type": "User",
        "site_admin": false
      },
      "html_url": "https://github.com/user1/test-repo",
      "description": null,
      "fork": false,
      "url": "https://api.github.com/repos/user1/test-repo",
      "forks_url": "https://api.github.com/repos/user1/test-repo/forks",
      "keys_url": "https://api.github.com/repos/user1/test-repo/keys{/key_id}",
      "collaborators_url": "https://api.github.com/repos/user1/test-repo/collaborators{/collaborator}",
      "teams_url": "https://api.github.com/repos/user1/test-repo/teams",
      "hooks_url": "https://api.github.com/repos/user1/test-repo/hooks",
      "issue_events_url": "https://api.github.com/repos/user1/test-repo/issues/events{/number}",
      "events_url": "https://api.github.com/repos/user1/test-repo/events",
      "assignees_url": "https://api.github.com/repos/user1/test-repo/assignees{/user}",
      "branches_url": "https://api.github.com/repos/user1/test-repo/branches{/branch}",
      "tags_url": "https://api.github.com/repos/user1/test-repo/tags",
      "blobs_url": "https://api.github.com/repos/user1/test-repo/git/blobs{/sha}",
      "git_tags_url": "https://api.github.com/repos/user1/test-repo/git/tags{/sha}",
      "git_refs_url": "https://api.github.com/repos/user1/test-repo/git/refs{/sha}",
      "trees_url": "https://api.github.com/repos/user1/test-repo/git/trees{/sha}",
      "statuses_url": "https://api.github.com/repos/user1/test-repo/statuses/{sha}",
      "languages_url": "https://api.github.com/repos/user1/test-repo/languages",
      "stargazers_url": "https://api.github.com/repos/user1/test-repo/stargazers",
      "contributors_url": "https://api.github.com/repos/user1/test-repo/contributors",
      "subscribers_url": "https://api.github.com/repos/user1/test-repo/subscribers",
      "subscription_url": "https://api.github.com/repos/user1/test-repo/subscription",
      "commits_url": "https://api.github.com/repos/user1/test-repo/commits{/sha}",
      "git_commits_url": "https://api.github.com/repos/user1/test-repo/git/commits{/sha}",
      "comments_url": "https://api.github.com/repos/user1/test-repo/comments{/number}",
      "issue_comment_url": "https://api.github.com/repos/user1/test-repo/issues/comments{/number}",
      "contents_url": "https://api.github.com/repos/user1/test-repo/contents/{+path}",
      "compare_url": "https://api.github.com/repos/user1/test-repo/compare/{base}...{head}",
      "merges_url": "https://api.github.com/repos/user1/test-repo/merges",
      "archive_url": "https://api.github.com/repos/user1/test-repo/{archive_format}{/ref}",
      "downloads_url": "https://api.github.com/repos/user1/test-repo/downloads",
      "issues_url": "https://api.github.com/repos/user1/test-repo/issues{/number}",
      "pulls_url": "https://api.github.com/repos/user1/test-repo/pulls{/number}",
      "milestones_url": "https://api.github.com/repos/user1/test-repo/milestones{/number}",
      "notifications_url": "https://api.github.com/repos/user1/test-repo/notifications{?since,all,participating}",
      "labels_url": "https://api.github.com/repos/user1/test-repo/labels{/name}",
      "releases_url": "https://api.github.com/repos/user1/test-repo/releases{/id}",
      "deployments_url": "https://api.github.com/repos/user1/test-repo/deployments",
      "created_at": "2024-01-25T18:15:05Z",
      "updated_at": "2024-01-25T18:15:05Z",
      "pushed_at": "2024-01-28T22:46:51Z",
      "git_url": "git://github.com/user1/test-repo.git",
      "ssh_url": "git@github.com:user1/test-repo.git",
      "clone_url": "https://github.com/user1/test-repo.git",
      "svn_url": "https://github.com/user1/test-repo",
      "homepage": null,
      "size": 5,
      "stargazers_count": 0,
      "watchers_count": 0,
      "language": null,
      "has_issues": true,
      "has_projects": true,
      "has_downloads": true,
      "has_wiki": false,
      "has_pages": false,
      "has_discussions": false,
      "forks_count": 0,
      "mirror_url": null,
      "archived": false,
      "disabled": false,
      "open_issues_count": 1,
      "license": null,
      "allow_forking": true,
      "is_template": false,
      "web_commit_signoff_required": false,
      "topics": [],
      "visibility": "private",
      "forks": 0,
      "open_issues": 1,
      "watchers": 0,
      "default_branch": "main",
      "permissions": {
        "admin": true,
        "maintain": true,
        "push": true,
        "triage": true,
        "pull": true
      },
      "temp_clone_token": "ANMLHS4CD5OHWWXIEZPACK3FW7TJ2",
      "allow_squash_merge": true,
      "allow_merge_commit": true,
      "allow_rebase_merge": true,
      "allow_auto_merge": false,
      "delete_branch_on_merge": false,
      "allow_update_branch": false,
      "use_squash_pr_title_as_default": false,
      "squash_merge_commit_message": "COMMIT_MESSAGES",
      "squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
      "merge_commit_message": "PR_TITLE",
      "merge_commit_title": "MERGE_MESSAGE",
      "network_count": 0,
      "subscribers_count": 1
    }
  }
} 

API Links

API NameAPI Documentation LinkAPI Link Visibility
Using GitHub REST APIhttps://docs.github.com/en/rest?apiVersion=2022-11-28Public

Get File - GitHub - REST

Get the contents of a file in a repository

Capabilities include:

  • The workflow is used to get the contents of a file in a repository

Entry Point IAP Component

The primary IAP component to run Get File - GitHub - REST is listed below:

IAP Component NameIAP Component Type
Get File - GitHub - RESTWorkflow

Inputs

The following table lists the inputs for Get File - GitHub - REST:

NameTypeRequiredDescriptionExample Value
repoOwnerstringyesThe account owner of the repository. The name is not case sensitive
user1
repoNamestringyesThe name of the repository without the .git extension. The name is not case sensitive
test-repo
filePathstringyesThe path to the file including the file name. For files in the root directory, this is just a file name
README.md
branchNamestringyesThe name of the branch
patch/issue-01
adapterIdstringyesThe GitHub adapter instance to use in the workflow
github

Outputs

The following table lists the outputs for Get File - GitHub - REST:

NameTypeDescriptionExample Value
fileResultobjectResult of successfully getting the file content
{
  "icode": "AD.200",
  "response": {
    "pathParam": "README.md",
    "pathParamQuery": "README.md",
    "content": "# test-repo This is draft readme",
    "name": "README.md",
    "sha": "4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
    "size": 33,
    "url": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=patch/issue-01",
    "html_url": "https://github.com/user1/test-repo/blob/patch/issue-01/README.md",
    "git_url": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
    "download_url": "https://raw.githubusercontent.com/user1/test-repo/patch/issue-01/README.md?token=token",
    "type": "file",
    "encoding": "base64",
    "_links": {
      "self": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=patch/issue-01",
      "git": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
      "html": "https://github.com/user1/test-repo/blob/patch/issue-01/README.md"
    }
  }
}
githubErrorobjectResult if failure getting the file content
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "github-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "response": {
        "message": "Not Found",
        "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
      },
      "redirects": 0,
      "tripTime": "1285ms"
    }
  },
  "response": {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
  }
}

Query Output

The following items show how to query successful results from the output of Get File - GitHub - REST:

File Content

fileResult.response.content

The following items show how to query failure results from the output of Get File - GitHub - REST:

Error Response Message

githubError.response.message

Example Inputs and Outputs

Example 1

Input:

{
  "repoOwner": "user1",
  "repoName": "test-repo",
  "filePath": "README.md",
  "branchName": "patch/issue-01",
  "adapterId": "github"
} 

Output:

{
  "fileResult": {
    "icode": "AD.200",
    "response": {
      "pathParam": "README.md",
      "pathParamQuery": "README.md",
      "content": "# test-repo\
This is draft readme",
      "name": "README.md",
      "sha": "4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
      "size": 33,
      "url": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=patch/issue-01",
      "html_url": "https://github.com/user1/test-repo/blob/patch/issue-01/README.md",
      "git_url": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
      "download_url": "https://raw.githubusercontent.com/user1/test-repo/patch/issue-01/README.md?token=token",
      "type": "file",
      "encoding": "base64",
      "_links": {
        "self": "https://api.github.com/repos/user1/test-repo/contents/README.md?ref=patch/issue-01",
        "git": "https://api.github.com/repos/user1/test-repo/git/blobs/4d1dbf2df64867d3d54c47b8a1fbb1367bba6d9e",
        "html": "https://github.com/user1/test-repo/blob/patch/issue-01/README.md"
      }
    }
  }
} 
Example 2

Input:

{
  "repoOwner": "user1",
  "repoName": "test-repo",
  "filePath": "test.js",
  "branchName": "patch/issue-01",
  "adapterId": "github"
} 

Output:

{
  "fileResponse": null,
  "githubError": {
    "icode": "AD.500",
    "IAPerror": {
      "origin": "github-connectorRest-handleEndResponse",
      "displayString": "Error 404 received on request",
      "recommendation": "Verify the request is accurate via debug logs and postman",
      "code": 404,
      "raw_response": {
        "status": "success",
        "code": 404,
        "response": {
          "message": "Not Found",
          "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
        },
        "redirects": 0,
        "tripTime": "1285ms"
      }
    },
    "response": {
      "message": "Not Found",
      "documentation_url": "https://docs.github.com/rest/repos/contents#get-repository-content"
    }
  }
} 

API Links

API NameAPI Documentation LinkAPI Link Visibility
Using GitHub REST APIhttps://docs.github.com/en/rest?apiVersion=2022-11-28Public

Additional Information

Support

Please use your Itential Customer Success account if you need support when using this Workflow Project.