GitHub
The github
module provides several helper functions to query GitHub, along with the connection information for more advanced usage.
Configuration
The github
configuration is automatically detected from the environment and git.
- The GitHub token is read from the
GITHUB_TOKEN
environment variable. Some queries might work without authentication for public repositories.
GitHub CodeSpaces
In a GitHub CodeSpace, the GITHUB_TOKEN
is automatically provisioned.
GitHub Actions
In GitHub Actions, you might need to add permissions to the workspace to access workflow logs and pull requests. You also need to pass the secret.GITHUB_TOKEN
to the GenAIScript script run.
Functions
Issues
You can query issues and issue comments using listIssues
and listIssueComments
.
Pull Requests
Query pull requests and pull request review comments using listPullRequests
and listPullRequestReviewComments
.
In GitHub Actions, ensure the pull-request: read
permission is granted.
Workflow Runs
Access the log of workflow runs to analyze failures with listWorkflowRuns
.
In GitHub Actions, grant the actions: read
permission.
Search Code
Use searchCode
for a code search on the default branch in the same repository.
Get File Content
Retrieve file content for a given ref, tag, or commit SHA using getFile
.
Get Repository Content
List files or directories at a path in a remote repository. By default, file contents from a directory are not loaded. Use downloadContent: true
.
Languages
Query the list of programming languages that GitHub computed for the repository using listRepositoryLanguages
.
Branches
List the branches on the repository using listBranches
.
Advanced Use
Utilize octokit to access the full GitHub APIs.
Install octokit in your list of packages: