Modules@robinpath/github
github

@robinpath/github

0.1.1Node.jsPublic

GitHub module for RobinPath.

GitHub

GitHub module for RobinPath.

Package: @robinpath/github | Category: Devops | Type: Integration

Authentication

github.setToken "ghp_xxxxxxxxxxxx"

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the github module when you need to:

  • Get repository information -- Use github.getRepo to perform this operation
  • List repositories for a user or the authenticated user -- Use github.listRepos to perform this operation
  • Create a new repository for the authenticated user -- Use github.createRepo to perform this operation
  • Delete a repository (requires delete_repo scope) -- Use github.deleteRepo to perform this operation
  • List branches in a repository -- Use github.listBranches to perform this operation

Quick Reference

FunctionDescriptionReturns
setTokenStore a GitHub personal access token for authentication{ok, message}
getRepoGet repository informationRepository object with name, description, stars, forks, etc.
listReposList repositories for a user or the authenticated userArray of repository objects
createRepoCreate a new repository for the authenticated userCreated repository object
deleteRepoDelete a repository (requires delete_repo scope){ok, status}
listBranchesList branches in a repositoryArray of branch objects with name and commit info
getBranchGet details for a specific branchBranch object with name, commit, and protection status
createBranchCreate a new branch from an existing branch refGit reference object for the new branch
listCommitsList commits in a repositoryArray of commit objects
getCommitGet a single commit by SHACommit object with files, stats, and metadata
listIssuesList issues in a repositoryArray of issue objects
createIssueCreate a new issue in a repositoryCreated issue object
updateIssueUpdate an existing issueUpdated issue object
closeIssueClose an issueUpdated issue object with state 'closed'
addIssueCommentAdd a comment to an issue or pull requestCreated comment object
listIssueCommentsList comments on an issue or pull requestArray of comment objects
listPullRequestsList pull requests in a repositoryArray of pull request objects
createPullRequestCreate a new pull requestCreated pull request object
mergePullRequestMerge a pull requestMerge result with SHA and message
listReleasesList releases in a repositoryArray of release objects
createReleaseCreate a new release from a tagCreated release object
listWorkflowsList GitHub Actions workflows in a repositoryWorkflows object with total_count and workflows array
triggerWorkflowTrigger a GitHub Actions workflow dispatch event{ok, status}
listWorkflowRunsList workflow runs for a repository or specific workflowWorkflow runs object with total_count and workflow_runs array
getUserGet a user profile or the authenticated userUser profile object
searchReposSearch GitHub repositoriesSearch results with total_count and items array
searchCodeSearch code across GitHub repositoriesSearch results with total_count and items array
listLabelsList labels in a repositoryArray of label objects with name, color, and description
createLabelCreate a new label in a repositoryCreated label object
addLabelsAdd labels to an issue or pull requestArray of label objects now on the issue
listMilestonesList milestones in a repositoryArray of milestone objects
createMilestoneCreate a new milestone in a repositoryCreated milestone object

Functions

setToken

Store a GitHub personal access token for authentication

Module: github | Returns: object -- {ok, message}

github.setToken "ghp_xxxxxxxxxxxx"
ParameterTypeRequiredDescription
tokenstringYesGitHub personal access token (ghp_... or fine-grained token)

getRepo

Get repository information

Module: github | Returns: object -- Repository object with name, description, stars, forks, etc.

github.getRepo "octocat" "Hello-World"
ParameterTypeRequiredDescription
ownerstringYesRepository owner (user or org)
repostringYesRepository name

listRepos

List repositories for a user or the authenticated user

Module: github | Returns: array -- Array of repository objects

github.listRepos "octocat"
ParameterTypeRequiredDescription
ownerstringNoUsername (omit for authenticated user)
optionsobjectNo{type?, sort?, direction?, perPage?, page?}

createRepo

Create a new repository for the authenticated user

Module: github | Returns: object -- Created repository object

github.createRepo "my-project" {"description": "A new project", "private": true, "autoInit": true}
ParameterTypeRequiredDescription
namestringYesRepository name
optionsobjectNo{description?, private?, autoInit?}

deleteRepo

Delete a repository (requires delete_repo scope)

Module: github | Returns: object -- {ok, status}

github.deleteRepo "myuser" "old-repo"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name

listBranches

List branches in a repository

Module: github | Returns: array -- Array of branch objects with name and commit info

github.listBranches "octocat" "Hello-World"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name

getBranch

Get details for a specific branch

Module: github | Returns: object -- Branch object with name, commit, and protection status

github.getBranch "octocat" "Hello-World" "main"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
branchstringYesBranch name

createBranch

Create a new branch from an existing branch ref

Module: github | Returns: object -- Git reference object for the new branch

github.createBranch "myuser" "my-repo" "feature-x" "main"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
branchNamestringYesName for the new branch
fromBranchstringNoSource branch (default: main)

listCommits

List commits in a repository

Module: github | Returns: array -- Array of commit objects

github.listCommits "octocat" "Hello-World" {"sha": "main", "perPage": 5}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
optionsobjectNo{sha?, path?, since?, until?, perPage?, page?}

getCommit

Get a single commit by SHA

Module: github | Returns: object -- Commit object with files, stats, and metadata

github.getCommit "octocat" "Hello-World" "abc1234"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
shastringYesCommit SHA

listIssues

List issues in a repository

Module: github | Returns: array -- Array of issue objects

github.listIssues "octocat" "Hello-World" {"state": "open", "labels": "bug"}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
optionsobjectNo{state?, labels?, assignee?, sort?, direction?, perPage?, page?}

createIssue

Create a new issue in a repository

Module: github | Returns: object -- Created issue object

github.createIssue "myuser" "my-repo" "Bug report" {"body": "Steps to reproduce...", "labels": ["bug"]}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
titlestringYesIssue title
optionsobjectNo{body?, labels?, assignees?, milestone?}

updateIssue

Update an existing issue

Module: github | Returns: object -- Updated issue object

github.updateIssue "myuser" "my-repo" 42 {"title": "Updated title", "labels": ["bug", "priority"]}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
issueNumbernumberYesIssue number
fieldsobjectYesFields to update: {title?, body?, state?, labels?, assignees?, milestone?}

closeIssue

Close an issue

Module: github | Returns: object -- Updated issue object with state 'closed'

github.closeIssue "myuser" "my-repo" 42
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
issueNumbernumberYesIssue number

addIssueComment

Add a comment to an issue or pull request

Module: github | Returns: object -- Created comment object

github.addIssueComment "myuser" "my-repo" 42 "This is fixed in v2.0"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
issueNumbernumberYesIssue or PR number
bodystringYesComment body (Markdown supported)

listIssueComments

List comments on an issue or pull request

Module: github | Returns: array -- Array of comment objects

github.listIssueComments "octocat" "Hello-World" 1
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
issueNumbernumberYesIssue or PR number

listPullRequests

List pull requests in a repository

Module: github | Returns: array -- Array of pull request objects

github.listPullRequests "octocat" "Hello-World" {"state": "open"}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
optionsobjectNo{state?, head?, base?, sort?, direction?, perPage?, page?}

createPullRequest

Create a new pull request

Module: github | Returns: object -- Created pull request object

github.createPullRequest "myuser" "my-repo" "Add feature X" "feature-x" "main" {"body": "Description here", "draft": false}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
titlestringYesPR title
headstringYesBranch containing changes
basestringYesBranch to merge into
optionsobjectNo{body?, draft?}

mergePullRequest

Merge a pull request

Module: github | Returns: object -- Merge result with SHA and message

github.mergePullRequest "myuser" "my-repo" 10 {"method": "squash"}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
prNumbernumberYesPull request number
optionsobjectNo{commitTitle?, commitMessage?, method?} method: merge

listReleases

List releases in a repository

Module: github | Returns: array -- Array of release objects

github.listReleases "octocat" "Hello-World"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name

createRelease

Create a new release from a tag

Module: github | Returns: object -- Created release object

github.createRelease "myuser" "my-repo" "v1.0.0" {"name": "Version 1.0", "body": "Release notes", "prerelease": false}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
tagNamestringYesTag name for the release (e.g. v1.0.0)
optionsobjectNo{name?, body?, draft?, prerelease?, targetCommitish?}

listWorkflows

List GitHub Actions workflows in a repository

Module: github | Returns: object -- Workflows object with total_count and workflows array

github.listWorkflows "myuser" "my-repo"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name

triggerWorkflow

Trigger a GitHub Actions workflow dispatch event

Module: github | Returns: object -- {ok, status}

github.triggerWorkflow "myuser" "my-repo" "deploy.yml" "main" {"environment": "production"}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
workflowIdstringYesWorkflow ID or filename (e.g. deploy.yml)
refstringYesBranch or tag ref to run on
inputsobjectNoWorkflow input parameters

listWorkflowRuns

List workflow runs for a repository or specific workflow

Module: github | Returns: object -- Workflow runs object with total_count and workflow_runs array

github.listWorkflowRuns "myuser" "my-repo" "ci.yml" {"status": "completed"}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
workflowIdstringNoWorkflow ID or filename (omit for all workflows)
optionsobjectNo{status?, branch?, event?, perPage?, page?}

getUser

Get a user profile or the authenticated user

Module: github | Returns: object -- User profile object

github.getUser "octocat"
ParameterTypeRequiredDescription
usernamestringNoGitHub username (omit for authenticated user)

searchRepos

Search GitHub repositories

Module: github | Returns: object -- Search results with total_count and items array

github.searchRepos "language:typescript stars:>1000" {"sort": "stars"}
ParameterTypeRequiredDescription
querystringYesSearch query (GitHub search syntax)
optionsobjectNo{sort?, order?, perPage?, page?}

searchCode

Search code across GitHub repositories

Module: github | Returns: object -- Search results with total_count and items array

github.searchCode "addClass repo:jquery/jquery" {"sort": "indexed"}
ParameterTypeRequiredDescription
querystringYesSearch query (GitHub code search syntax)
optionsobjectNo{sort?, order?, perPage?, page?}

listLabels

List labels in a repository

Module: github | Returns: array -- Array of label objects with name, color, and description

github.listLabels "octocat" "Hello-World"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name

createLabel

Create a new label in a repository

Module: github | Returns: object -- Created label object

github.createLabel "myuser" "my-repo" "priority:high" "ff0000" "High priority issues"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
namestringYesLabel name
colorstringYesLabel color hex (e.g. 'ff0000' or '#ff0000')
descriptionstringNoLabel description

addLabels

Add labels to an issue or pull request

Module: github | Returns: array -- Array of label objects now on the issue

github.addLabels "myuser" "my-repo" 42 ["bug", "priority:high"]
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
issueNumbernumberYesIssue or PR number
labelsarrayYesArray of label names to add

listMilestones

List milestones in a repository

Module: github | Returns: array -- Array of milestone objects

github.listMilestones "octocat" "Hello-World"
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name

createMilestone

Create a new milestone in a repository

Module: github | Returns: object -- Created milestone object

github.createMilestone "myuser" "my-repo" "v2.0" {"description": "Version 2.0 release", "dueOn": "2025-06-01T00:00:00Z"}
ParameterTypeRequiredDescription
ownerstringYesRepository owner
repostringYesRepository name
titlestringYesMilestone title
optionsobjectNo{description?, state?, dueOn?} dueOn is ISO 8601 date

Error Handling

All functions throw on failure. Common errors:

ErrorCause
GitHub token not set. Call github.setToken first.Check the error message for details
GitHub API ${method} ${path} failed (${response.status}): ${String(msg)}Check the error message for details
Token is requiredCheck the error message for details
owner and repo are requiredCheck the error message for details
Repository name is requiredCheck the error message for details
owner, repo, and branch are requiredCheck the error message for details
owner, repo, and branchName are requiredCheck the error message for details
owner, repo, and sha are requiredCheck the error message for details
@desc "Get repo and validate result"
do
  set $result as github.getRepo "octocat" "Hello-World"
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate Repo

Retrieve all items and loop through them.

@desc "Setup authentication"
do
  github.setToken $token
enddo

@desc "Get repo and iterate results"
do
  set $result as github.getRepo "octocat" "Hello-World"
  each $item in $result
    print $item
  end
enddo

2. Create a new item with createRepo

Create a new resource and capture the result.

@desc "Setup authentication"
do
  github.setToken $token
enddo

@desc "Create repo"
do
  set $result as github.createRepo "my-project" {"description": "A new project", "private": true, "autoInit": true}
  print "Created: " + $result
enddo

3. Create and update workflow

Create an item and then update it.

@desc "Setup authentication"
do
  github.setToken $token
enddo

@desc "Create repo and update issue"
do
  set $created as github.createRepo "my-project" {"description": "A new project", "private": true, "autoInit": true}
  # Update the created item
  github.updateIssue "myuser" "my-repo" 42 {"title": "Updated title", "labels": ["bug", "priority"]}
enddo

4. Check before creating

List existing items and only create if needed.

@desc "Setup authentication"
do
  github.setToken $token
enddo

@desc "Get repo and create repo"
do
  set $existing as github.getRepo "octocat" "Hello-World"
  if $existing == null
    github.createRepo "my-project" {"description": "A new project", "private": true, "autoInit": true}
    print "Item created"
  else
    print "Item already exists"
  end
enddo

5. Multi-step GitHub workflow

Chain multiple github operations together.

@desc "Setup authentication"
do
  github.setToken $token
enddo

@desc "Get repo, list repos, and more"
do
  set $r_getRepo as github.getRepo "octocat" "Hello-World"
  set $r_listRepos as github.listRepos "octocat"
  set $r_createRepo as github.createRepo "my-project" {"description": "A new project", "private": true, "autoInit": true}
  print "All operations complete"
enddo

6. Safe getRepo with validation

Check results before proceeding.

@desc "Setup authentication"
do
  github.setToken $token
enddo

@desc "Get repo and validate result"
do
  set $result as github.getRepo "octocat" "Hello-World"
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • docker -- Docker module for complementary functionality
  • git -- Git module for complementary functionality
  • gitlab -- GitLab module for complementary functionality
  • vercel -- Vercel module for complementary functionality
  • netlify -- Netlify module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/github

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size11.1 KB
Versions1
Weekly Downloads29
Total Downloads29
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

devops