Logo

GitHub

Authentication Type: API Key
Description: Integrate with GitHub to read repository files and create pull requests.


Repositories

Operations for GitHub repositories.

Read File

Reads a file from a GitHub repository.

Operation Type: Query (Read)

Parameters:

  • owner string (required): The repository owner (username or organization)
  • repo string (required): The repository name
  • path string (required): The file path within the repository
  • ref string (required): The branch, tag, or commit SHA to read from (defaults to main branch)

Returns:

  • content string: The file content (base64 decoded)
  • encoding string: The encoding of the file content
  • size number: The size of the file in bytes
  • sha string: The SHA of the file
  • path string: The file path

Example Usage:

{
  "owner": "facebook",
  "repo": "react",
  "path": "README.md",
  "ref": "main"
}

Get Branch SHA

Gets the SHA of a specific branch.

Operation Type: Query (Read)

Parameters:

  • owner string (required): The repository owner (username or organization)
  • repo string (required): The repository name
  • branch string (required): The branch name to get the SHA for

Returns:

  • sha string: The SHA of the branch
  • branch string: The branch name

Example Usage:

{
  "owner": "microsoft",
  "repo": "vscode",
  "branch": "main"
}

Create Branch

Creates a new branch in a GitHub repository.

Operation Type: Mutation (Write)

Parameters:

  • owner string (required): The repository owner (username or organization)
  • repo string (required): The repository name
  • branch string (required): The name of the new branch
  • baseSha string (required): The SHA to base the new branch on

Returns:

  • ref string: The reference name (refs/heads/branch-name)
  • sha string: The SHA of the new branch
  • branch string: The branch name

Example Usage:

{
  "owner": "myorg",
  "repo": "myproject",
  "branch": "feature/new-api-endpoint",
  "baseSha": "abc123def456789"
}

Create File

Creates a new file in a GitHub repository.

Operation Type: Mutation (Write)

Parameters:

  • owner string (required): The repository owner (username or organization)
  • repo string (required): The repository name
  • path string (required): The file path within the repository
  • message string (required): The commit message
  • content string (required): The file content (will be base64 encoded)
  • branch string (required): The branch to create the file in

Returns:

  • content object: The created file information
    • name string: The file name
    • path string: The file path
    • sha string: The SHA of the file
  • commit object: The commit information
    • sha string: The SHA of the commit
    • message string: The commit message

Example Usage:

{
  "owner": "myorg",
  "repo": "myproject",
  "path": "src/components/NewComponent.js",
  "message": "Add new React component for user authentication",
  "content": "import React from 'react';\n\nconst NewComponent = () => {\n  return <div>Hello World</div>;\n};\n\nexport default NewComponent;",
  "branch": "feature/new-component"
}

Update File

Updates an existing file in a GitHub repository.

Operation Type: Mutation (Write)

Parameters:

  • owner string (required): The repository owner (username or organization)
  • repo string (required): The repository name
  • path string (required): The file path within the repository
  • message string (required): The commit message
  • content string (required): The new file content (will be base64 encoded)
  • sha string (required): The SHA of the file being updated
  • branch string (required): The branch to update the file in

Returns:

  • content object: The updated file information
    • name string: The file name
    • path string: The file path
    • sha string: The SHA of the updated file
  • commit object: The commit information
    • sha string: The SHA of the commit
    • message string: The commit message

Example Usage:

{
  "owner": "myorg",
  "repo": "myproject",
  "path": "src/components/ExistingComponent.js",
  "message": "Fix bug in user authentication logic",
  "content": "import React from 'react';\n\nconst ExistingComponent = () => {\n  // Fixed authentication logic\n  return <div>Updated Component</div>;\n};\n\nexport default ExistingComponent;",
  "sha": "def456abc789123",
  "branch": "bugfix/auth-issue"
}

Create Pull Request

Creates a new pull request in a GitHub repository.

Operation Type: Mutation (Write)

Parameters:

  • owner string (required): The repository owner (username or organization)
  • repo string (required): The repository name
  • title string (required): The title of the pull request
  • body string (required): The body/description of the pull request
  • head string (required): The branch containing the changes (source branch)
  • base string (required): The branch to merge into (target branch)
  • draft boolean (required): Whether to create the pull request as a draft

Returns:

  • number number: The pull request number
  • htmlUrl string: The URL to view the pull request
  • state string: The state of the pull request
  • title string: The title of the pull request

Example Usage:

{
  "owner": "myorg",
  "repo": "myproject",
  "title": "Add user authentication system",
  "body": "This PR introduces a comprehensive user authentication system with the following features:\n\n- JWT token-based authentication\n- Password hashing with bcrypt\n- Login/logout functionality\n- Protected route middleware\n\nFixes #123",
  "head": "feature/user-auth",
  "base": "main",
  "draft": false
}

Common Use Cases

Automated Code Management:

  • Read configuration files and documentation from repositories for automated deployments
  • Create feature branches programmatically for automated development workflows
  • Update version files, changelogs, and documentation as part of CI/CD pipelines

Development Workflow Automation:

  • Create pull requests automatically after completing automated code changes or fixes
  • Update files across multiple repositories for synchronized releases or security patches
  • Generate and commit automated reports, test results, or code coverage files

Code Review and Collaboration:

  • Create draft pull requests for work-in-progress features to enable early feedback
  • Update files based on code review suggestions or automated linting fixes
  • Manage feature branch creation and file updates for collaborative development projects

Repository Maintenance:

  • Read and analyze repository files for automated code quality checks and security scanning
  • Create documentation updates and commit them directly to appropriate branches
  • Update configuration files across multiple repositories for consistent development environments