Skip to content

createGitHubClient

createGitHubClient(opts): object

Defined in: index.ts:130

Creates a GitHub client with a group of methods per API area (branches, pulls, issues, secrets and so on), backed by one REST client and one GraphQL client built from the same options.

GitHubClientOptions

branches: object

listBranches: (repo) => Promise<GitHubBranch[]>

Every branch, read a page at a time until a page comes back short.

string

Promise<GitHubBranch[]>

protectBranch: (repo, branch, payload) => Promise<void>

string

string

Record<string, unknown>

Promise<void>

removeBranch: (repo, branch) => Promise<void>

Delete one branch’s ref. The name keeps its /s; each segment is encoded.

string

string

Promise<void>

checks: object

createCheckRun: (repo, input) => Promise<GitHubCheckRun>

string

CreateCheckRunInput

Promise<GitHubCheckRun>

listCheckRunsForRef: (repo, ref) => Promise<GitHubCheckRun[]>

Every check run on a commit, read a page at a time until a page comes back short.

string

string

Promise<GitHubCheckRun[]>

updateCheckRun: (repo, checkRunId, input) => Promise<GitHubCheckRun>

Patches an existing check run — used to move a "queued" run posted before a dispatched task ran to "completed" once it finishes.

string

number

UpdateCheckRunInput

Promise<GitHubCheckRun>

environments: object

deleteEnvironment: (repo, name) => Promise<void>

string

string

Promise<void>

listEnvironments: (repo) => Promise<GitHubEnvironment[]>

Every environment, all pages: GitHub lists 30 by default and at most 100 a page.

string

Promise<GitHubEnvironment[]>

upsertEnvironment: (repo, name, body) => Promise<void>

string

string

Record<string, unknown>

Promise<void>

git: object

createBlob: (repo, content, encoding) => Promise<GitBlob>

string

string

string = "utf-8"

Promise<GitBlob>

createCommit: (repo, message, tree, parents) => Promise<GitCommit>

string

string

string

string[]

Promise<GitCommit>

createPull: (repo, input) => Promise<GitPull>

string

CreatePullInput

Promise<GitPull>

createRef: (repo, ref, sha) => Promise<GitRef>

string

string

string

Promise<GitRef>

createTree: (repo, tree, baseTree?) => Promise<GitTree>

string

object[]

string

Promise<GitTree>

getCommit: (repo, sha) => Promise<GitCommit>

string

string

Promise<GitCommit>

getContents: (repo, path, ref?) => Promise<GitContents>

ref defaults to the repo’s default branch (GitHub’s own default) when omitted — the security-relevant choice every existing caller relies on (D4/D6, validateConfig()’s own docstring). Pass it explicitly to read a specific commit/branch’s content instead — a same-repo PR branch is no longer a new trust boundary for this org (D6-amended, tech-sentinel-ci-runner.spec.md), just never a fork’s.

string

string

string

Promise<GitContents>

getRef: (repo, branch) => Promise<GitRef>

string

string

Promise<GitRef>

getTree: (repo, sha, recursive) => Promise<GitTree>

string

string

boolean = false

Promise<GitTree>

listDirectory: (repo, path, options) => Promise<GitDirectoryEntry[]>

Lists the directory at path through the contents API (GET /repos/:repo/contents/:path, which answers an array for a directory). A 404 (no such directory) is an empty list, not an error; any other failure is the usual ProviderApiError. One request lists one level: with recursive: true it makes one more request per nested directory and returns a flat list of full paths (directories included). A path that is a file, not a directory, throws.

string

string

ListDirectoryOptions = {}

Promise<GitDirectoryEntry[]>

listTree: (repo, path, options) => Promise<GitDirectoryEntry[] | undefined>

Lists a directory and everything under it in ONE request, through the git trees API (GET /repos/:repo/git/trees/<ref>:<path>?recursive=1), as the same flat list of full paths listDirectory(..., { recursive: true }) returns, which makes one request per directory. It answers undefined, so the caller can list the directory the other way, when it cannot answer for certain: a ref that is not the default branch, a full commit SHA or a branch name with no slash (a name with a slash is ambiguous in this form and GitHub answers 404), a tree GitHub cut short (truncated), a directory GitHub says it does not have (404) or a request it cannot read (422). Any other failure throws. Checked against the live API with HEAD, a commit SHA and a plain branch name, and a missing directory.

string

string

Pick<ListDirectoryOptions, "ref"> = {}

Promise<GitDirectoryEntry[] | undefined>

putContents: (repo, path, input) => Promise<PutContentsResult>

PUT /repos/:repo/contents/:path — creates or updates one file in a single commit. Pass sha when updating so a concurrent change is refused (409) and not silently overwritten.

string

string

PutContentsInput

Promise<PutContentsResult>

updateRef: (repo, ref, sha, force) => Promise<GitRef>

string

string

string

boolean = false

Promise<GitRef>

graphql: GraphQLClient

The GraphQL client, for the callers whose API (Projects v2) has no REST form.

hooks: object

createHook: (scope, input) => Promise<GitHubHook>

Makes a JSON webhook that delivers to url, signed with secret.

HookScope

CreateHookInput

Promise<GitHubHook>

listHooks: (scope) => Promise<GitHubHook[]>

Every webhook in the scope, read page by page.

HookScope

Promise<GitHubHook[]>

updateHook: (scope, id, input) => Promise<GitHubHook>

Changes a webhook’s events or active flag; the config (URL and secret) is not sent, so it stays.

HookScope

number

UpdateHookInput

Promise<GitHubHook>

issueFields: object

addValues: (repo, number, values) => Promise<GitHubIssueFieldValue[]>

Adds values to an issue without touching the others it has. The caller needs push access to the repository. (GitHub’s PUT on the same path replaces every value of the issue, so this client never uses it.)

string

number

IssueFieldValueInput[]

Promise<GitHubIssueFieldValue[]>

deleteValue: (repo, number, fieldId) => Promise<void>

Removes an issue’s value for one field.

string

number

number

Promise<void>

list: (org) => Promise<GitHubIssueField[]>

The issue fields an organization defines (read-only).

string

Promise<GitHubIssueField[]>

values: (repo, number) => Promise<GitHubIssueFieldValue[]>

The values an issue has for the organization’s issue fields (read-only).

string

number

Promise<GitHubIssueFieldValue[]>

issues: object

addBlockedBy: (repo, number, blockerId) => Promise<GitHubIssue>

Records that blockerId (an issue’s numeric id) blocks the issue number.

string

number

number

Promise<GitHubIssue>

addLabels: (repo, number, labels) => Promise<void>

string

number

string[]

Promise<void>

addSubIssue: (repo, number, subIssueId, replaceParent) => Promise<GitHubIssue>

Makes subIssueId (an issue’s numeric id, not its number) a sub-issue of the issue number; replaceParent moves it from another parent.

string

number

number

boolean = false

Promise<GitHubIssue>

countSearch: (repo, query) => Promise<number>

How many issues a search matches inside one repository (GET /search/issues, one item asked for, only the count read). The query is the text of GitHub’s filter box; repo:<repo> is added. A query the search refuses answers 422.

string

string

Promise<number>

createComment: (repo, number, body) => Promise<void>

string

number

string

Promise<void>

createIssue: (repo, body) => Promise<GitHubIssue>

string

Record<string, unknown>

Promise<GitHubIssue>

createMilestone: (repo, title) => Promise<GitHubMilestone>

string

string

Promise<GitHubMilestone>

getIssue: (repo, number) => Promise<GitHubIssue>

string

number

Promise<GitHubIssue>

getParent: (repo, number) => Promise<GitHubIssue | null>

The parent of the issue number, or null when it has none (GitHub answers 404).

string

number

Promise<GitHubIssue | null>

listBlockedBy: (repo, number) => Promise<GitHubIssue[]>

The issues that block the issue number.

string

number

Promise<GitHubIssue[]>

listComments: (repo, number) => Promise<GitHubIssueComment[]>

string

number

Promise<GitHubIssueComment[]>

listIssues: (repo, params) => Promise<GitHubIssue[]>

string

IssueSearchParams = {}

Promise<GitHubIssue[]>

listMilestones: (repo, params) => Promise<GitHubMilestone[]>

string

"open" | "closed" | "all"

Promise<GitHubMilestone[]>

removeBlockedBy: (repo, number, blockerId) => Promise<GitHubIssue>

Removes the record that blockerId (an issue’s numeric id) blocks the issue number.

string

number

number

Promise<GitHubIssue>

removeLabel: (repo, number, label) => Promise<void>

string

number

string

Promise<void>

removeSubIssue: (repo, number, subIssueId) => Promise<GitHubIssue>

Takes subIssueId (an issue’s numeric id) off the issue number, its parent.

string

number

number

Promise<GitHubIssue>

updateIssue: (repo, number, body) => Promise<GitHubIssue>

string

number

Record<string, unknown>

Promise<GitHubIssue>

issueTypes: object

create: (org, input) => Promise<OrgIssueTypeInfo>

Makes a Type.

string

IssueTypeInput

Promise<OrgIssueTypeInfo>

list: (org) => Promise<OrgIssueTypeInfo[]>

The Types the organization has.

string

Promise<OrgIssueTypeInfo[]>

update: (org, id, input) => Promise<OrgIssueTypeInfo>

Replaces a Type: send back the name and is_enabled it already has, or they change.

string

number

IssueTypeInput

Promise<OrgIssueTypeInfo>

labels: object

createLabel: (repo, body) => Promise<GitHubLabel>

string

string

string

string

Promise<GitHubLabel>

deleteLabel: (repo, name) => Promise<void>

string

string

Promise<void>

listLabels: (repo) => Promise<GitHubLabel[]>

Every label, all pages.

string

Promise<GitHubLabel[]>

updateLabel: (repo, name, body) => Promise<GitHubLabel>

string

string

string

string

Promise<GitHubLabel>

pages: object

createPages: (repo, payload) => Promise<GitHubPages>

Enables Pages for the first time. Throws on all errors except 409 Conflict (already enabled — callers should catch that and fall through to updatePages).

string

CreatePagesPayload

Promise<GitHubPages>

getPages: (repo) => Promise<GitHubPages | null>

Returns null when Pages is not yet enabled (404).

string

Promise<GitHubPages | null>

updatePages: (repo, payload) => Promise<void>

Updates Pages settings on an existing site (build type, cname, https). GitHub returns 204 No Content.

string

UpdatePagesPayload

Promise<void>

properties: object

getValues: (repo) => Promise<RepoPropertyValue[]>

The custom property values set on a repository (read-only).

string

Promise<RepoPropertyValue[]>

orgSchema: (org) => Promise<OrgProperty[]>

The custom properties an organization defines, with their types and allowed values (read-only). The token needs read access to the organization’s custom properties.

string

Promise<OrgProperty[]>

setOrgProperty: (org, property) => Promise<OrgProperty>

Creates or replaces one custom property definition of the organization. GitHub replaces the whole definition, so send back every field the property already has (orgSchema has them); a field left out is reset. The token needs write access to the organization’s custom properties (Custom properties: admin).

string

OrgProperty

Promise<OrgProperty>

setProperties: (repo, values) => Promise<void>

value is a plain string for string/single_select/true_false custom properties, or a string array for multi_select ones — GitHub’s own PATCH body accepts either per property. A single-string comma-joined value has no length ceiling GitHub documents, but real usage hits one in practice (a string-type property with enough joined values 422s as “too long”); multi_select has none.

string

Record<string, string | string[]>

Promise<void>

pulls: object

createPullRequest: (repo, input) => Promise<GitHubPullRequest>

Opens a pull request (POST /pulls). GitHub answers 422 when the head has no commit beyond the base or a pull request for the same head and base is already open.

string

CreatePullRequestInput

Promise<GitHubPullRequest>

createReview: (repo, number, input) => Promise<GitHubPullRequestReview>

Submits a review in one call — GitHub has no separate “create draft, then submit” step when event is provided directly (the multi-step PENDING review flow exists for the web UI’s own draft-comments experience, not needed here).

string

number

CreateReviewInput

Promise<GitHubPullRequestReview>

getPullRequest: (repo, number) => Promise<GitHubPullRequest>

string

number

Promise<GitHubPullRequest>

listCommits: (repo, number) => Promise<GitHubPullRequestCommit[]>

A PR’s own commits, in commit order. per_page=100 — GitHub’s max — covers every real PR in this org; a PR genuinely exceeding 100 commits (GitHub caps this endpoint at 250 regardless of pagination) is an edge case no consumer here needs to paginate for today.

string

number

Promise<GitHubPullRequestCommit[]>

listFiles: (repo, number) => Promise<GitHubPullRequestFile[]>

A PR’s own changed files, read a page at a time until a page comes back short. GitHub serves at most 3000 files from this endpoint, so a larger PR is cut at that cap.

string

number

Promise<GitHubPullRequestFile[]>

listOpenByHead: (repo, branch) => Promise<GitHubPullRequest[]>

The open pull requests whose head is branch of the repository itself (GET /pulls?head=owner:branch).

string

string

Promise<GitHubPullRequest[]>

listPullRequests: (repo, state) => Promise<GitHubPullRequest[]>

Every pull request in one state, newest first, read a page at a time until a page comes back short. closed includes the merged ones; tell them apart by merged_at.

string

"open" | "closed"

Promise<GitHubPullRequest[]>

listReviews: (repo, number) => Promise<GitHubPullRequestReview[]>

A PR’s reviews, oldest first. per_page=100 covers every real PR in this org.

string

number

Promise<GitHubPullRequestReview[]>

listReviewThreads: (repo, number) => Promise<ReviewThread[]>

Every review thread on a PR, resolved or not — GraphQL-only, first: 100 covers every real PR’s review-thread count in this org today; no consumer needs pagination yet.

string

number

Promise<ReviewThread[]>

markReadyForReview: (nodeId) => Promise<void>

Takes a draft pull request out of draft (GraphQL markPullRequestReadyForReview; REST has no call). Takes the node id, which a pull request read carries as node_id.

string

Promise<void>

resolveReviewThread: (threadId) => Promise<void>

Marks one review thread resolved. Requires Contents: Write — confirmed directly against GitHub’s own behavior (surprising, since resolving a thread creates no commit, touches no file, moves no ref — it only toggles a boolean on PR conversation metadata), not Pull requests: Write the way createReview() needs.

string

Promise<void>

updatePullRequest: (repo, number, input) => Promise<GitHubPullRequest>

Changes a pull request’s own fields (PATCH /pulls/{number}). Labels, assignees and the milestone are the issues API’s.

string

number

UpdatePullRequestInput

Promise<GitHubPullRequest>

repos: object

getContents: (repo, path) => Promise<GitHubContents>

string

string

Promise<GitHubContents>

getRepo: (repo) => Promise<GitHubRepo>

string

Promise<GitHubRepo>

updateRepo: (repo, settings) => Promise<void>

string

Record<string, unknown>

Promise<void>

rulesets: object

createRuleset: (repo, payload) => Promise<GitHubRuleset>

string

Record<string, unknown>

Promise<GitHubRuleset>

getRuleset: (repo, id) => Promise<GitHubRulesetDetail>

string

number

Promise<GitHubRulesetDetail>

listRulesets: (repo) => Promise<GitHubRuleset[]>

string

Promise<GitHubRuleset[]>

updateRuleset: (repo, id, payload) => Promise<GitHubRuleset>

string

number

Record<string, unknown>

Promise<GitHubRuleset>

secrets: object

deleteSecret: (repo, scope, name) => Promise<void>

string

SecretScope

string

Promise<void>

getPublicKey: (repo, scope) => Promise<GitHubPublicKey>

string

SecretScope

Promise<GitHubPublicKey>

listOrgSecretInfo: (org) => Promise<OrgSecretInfo[]>

The organization’s secrets with their visibility, names only, all pages.

string

Promise<OrgSecretInfo[]>

listSecrets: (repo, scope) => Promise<string[]>

Every secret name in the scope, all pages: GitHub lists 30 by default and at most 100 a page.

string

SecretScope

Promise<string[]>

listSelectedRepositories: (org, name) => Promise<string[]>

The names of the repositories that can read one organization secret of visibility selected, all pages.

string

string

Promise<string[]>

putSecret: (repo, scope, name, body) => Promise<void>

string

SecretScope

string

Record<string, unknown>

Promise<void>

security: object

automatedSecurityFixesEnabled: (repo) => Promise<boolean>

Whether Dependabot security updates are on.

string

Promise<boolean>

codeScanningDefaultSetupState: (repo) => Promise<string>

The state of CodeQL default setup: configured or not-configured.

string

Promise<string>

disableDefaultCodeScanning: (repo) => Promise<void>

string

Promise<void>

enableAutomatedSecurityFixes: (repo) => Promise<void>

string

Promise<void>

enableCodeScanning: (repo) => Promise<CodeScanningSetupResult>

string

Promise<CodeScanningSetupResult>

enableDependencyGraph: (repo) => Promise<void>

string

Promise<void>

security.enablePrivateVulnerabilityReporting

Section titled “security.enablePrivateVulnerabilityReporting”

enablePrivateVulnerabilityReporting: (repo) => Promise<void>

string

Promise<void>

enableSecretScanning: (repo) => Promise<void>

string

Promise<void>

enableVulnerabilityAlerts: (repo) => Promise<void>

string

Promise<void>

security.privateVulnerabilityReportingEnabled

Section titled “security.privateVulnerabilityReportingEnabled”

privateVulnerabilityReportingEnabled: (repo) => Promise<boolean>

Whether private vulnerability reporting is on.

string

Promise<boolean>

vulnerabilityAlertsEnabled: (repo) => Promise<boolean>

Whether vulnerability alerts are on: GitHub answers 204 when they are and 404 when they are not.

string

Promise<boolean>

statuses: object

listCommitStatuses: (repo, ref) => Promise<GitHubCommitStatus[]>

Every commit status on a ref, newest first (GET /commits/{ref}/statuses), read a page at a time until a page comes back short. A context that posted more than once appears once per post: the first one is the current state.

string

string

Promise<GitHubCommitStatus[]>

teams: object

addRepo: (org, teamSlug, owner, repo, permission) => Promise<void>

string

string

string

string

TeamPermission

Promise<void>

listForRepo: (repo) => Promise<RepoTeam[]>

The teams that have access to a repository, with each team’s permission there (read-only).

string

Promise<RepoTeam[]>

members: (org, teamSlug) => Promise<TeamMember[]>

Every member of a team (maintainers included), read page by page. Members of child teams are included, as GitHub does. A 404 means the team does not exist or the token cannot see it.

string

string

Promise<TeamMember[]>

topics: object

setTopics: (repo, names) => Promise<void>

string

string[]

Promise<void>

user: object

getCurrentUser: () => Promise<GitHubUser>

Promise<GitHubUser>

getCurrentUserWithExpiry(): Promise<GitHubUserWithExpiry>

The authenticated user plus when the token expires, read from the response header on the same call.

Promise<GitHubUserWithExpiry>

variables: object

createVariable: (repo, scope, body) => Promise<void>

string

VariableScope

Record<string, unknown>

Promise<void>

deleteVariable: (repo, scope, name) => Promise<void>

string

VariableScope

string

Promise<void>

getVariable: (repo, scope, name) => Promise<GitHubVariable | null>

One variable, or null when the scope has none of that name.

string

VariableScope

string

Promise<GitHubVariable | null>

listVariables: (repo, scope) => Promise<GitHubVariable[]>

Every variable in the scope, read page by page, with its value.

string

VariableScope

Promise<GitHubVariable[]>

updateVariable: (repo, scope, name, body) => Promise<void>

string

VariableScope

string

Record<string, unknown>

Promise<void>

workflows: object

createWorkflowDispatch: (repo, workflowFile, ref, inputs?) => Promise<void>

Triggers a workflow_dispatch run. workflowFile is the workflow’s filename (e.g. "platform.dispatchedCheck.yml") — GitHub accepts the filename directly, no numeric workflow ID lookup needed. Fire-and-forget: the API returns 204 with no run ID, so callers needing to correlate the resulting run back to this call must pass their own correlation value through inputs (visible in the Actions UI/logs — never a secret).

string

string

string

Record<string, string>

Promise<void>

getRun: (repo, id) => Promise<GitHubWorkflowRun>

string

string | number

Promise<GitHubWorkflowRun>

listJobs: (repo, runId) => Promise<GitHubWorkflowJob[]>

Lists the jobs of one run, steps included (one request, first page of up to 100 jobs).

string

string | number

Promise<GitHubWorkflowJob[]>

listRuns: (repo, filter?) => Promise<GitHubWorkflowRun[]>

string

WorkflowRunFilter

Promise<GitHubWorkflowRun[]>