Table of Contents

Interface IGitHubService

Namespace
Ando.Server.GitHub
Assembly
Ando.Server.dll

Service for interacting with the GitHub API.

public interface IGitHubService

Methods

CloneRepositoryAsync(long, string, string, string, string, string?)

Clones a repository to the specified directory.

Task<bool> CloneRepositoryAsync(long installationId, string repoFullName, string branch, string commitSha, string targetDirectory, string? gitTokenOverride = null)

Parameters

installationId long

GitHub App installation ID.

repoFullName string

Repository full name (owner/repo).

branch string

Branch to clone.

commitSha string

Specific commit to checkout.

targetDirectory string

Directory to clone into.

gitTokenOverride string

Optional GitHub token to use for git operations (clone/fetch/push) instead of an installation token. Useful when build scripts need to push tags/commits and the GitHub App token lacks write permissions.

Returns

Task<bool>

FetchAndCheckoutAsync(long, string, string, string, string, string?)

Fetches latest changes for an already cloned repository.

Task<bool> FetchAndCheckoutAsync(long installationId, string repoFullName, string branch, string commitSha, string repoDirectory, string? gitTokenOverride = null)

Parameters

installationId long

GitHub App installation ID.

repoFullName string

Repository full name (owner/repo).

branch string

Branch to fetch.

commitSha string

Specific commit to checkout.

repoDirectory string

Directory containing the repository.

gitTokenOverride string

Optional GitHub token to use for git operations (fetch/checkout/push) instead of an installation token. Useful when build scripts need to push tags/commits and the GitHub App token lacks write permissions.

Returns

Task<bool>

GetAppSlugAsync()

Gets the GitHub App slug (used in URLs like https://github.com/apps/{slug}). This is fetched from the GitHub API using the app JWT and is more reliable than configuring the slug manually.

Task<string?> GetAppSlugAsync()

Returns

Task<string>

GetBranchHeadShaAsync(long, string, string)

Gets the latest commit SHA for a branch.

Task<string?> GetBranchHeadShaAsync(long installationId, string repoFullName, string branch)

Parameters

installationId long

GitHub App installation ID.

repoFullName string

Repository full name (owner/repo).

branch string

Branch name.

Returns

Task<string>

Commit SHA, or null if not found.

GetFileContentAsync(long, string, string, string?)

Gets the content of a file from a repository.

Task<string?> GetFileContentAsync(long installationId, string repoFullName, string filePath, string? branch = null)

Parameters

installationId long

GitHub App installation ID.

repoFullName string

Repository full name (owner/repo).

filePath string

Path to the file within the repository.

branch string

Branch or commit ref (optional, defaults to default branch).

Returns

Task<string>

File content, or null if not found.

GetInstallationRepositoriesAsync(long)

Gets repositories accessible to an installation.

Task<IReadOnlyList<GitHubRepository>> GetInstallationRepositoriesAsync(long installationId)

Parameters

installationId long

GitHub App installation ID.

Returns

Task<IReadOnlyList<GitHubRepository>>

GetInstallationTokenAsync(long)

Gets an installation access token for API calls.

Task<string?> GetInstallationTokenAsync(long installationId)

Parameters

installationId long

GitHub App installation ID.

Returns

Task<string>

GetRepositoryInstallationAsync(string)

Gets the GitHub App installation ID for a repository. Uses the App's JWT to authenticate.

Task<(long InstallationId, GitHubRepository Repository)?> GetRepositoryInstallationAsync(string repoFullName)

Parameters

repoFullName string

Repository full name (owner/repo).

Returns

Task<(long InstallationId, GitHubRepository Repository)?>

Installation ID and repository info, or null if not installed.

GetUserRepositoriesAsync(string)

Gets repositories accessible to a user via their access token.

Task<IReadOnlyList<GitHubRepository>> GetUserRepositoriesAsync(string accessToken)

Parameters

accessToken string

User's OAuth access token.

Returns

Task<IReadOnlyList<GitHubRepository>>

SetCommitStatusAsync(long, string, string, CommitStatusState, string?, string?, string)

Posts a commit status to GitHub.

Task<bool> SetCommitStatusAsync(long installationId, string repoFullName, string commitSha, CommitStatusState state, string? description = null, string? targetUrl = null, string context = "ci/ando")

Parameters

installationId long

GitHub App installation ID.

repoFullName string

Repository full name (owner/repo).

commitSha string

Commit SHA to update.

state CommitStatusState

Status state (pending, success, failure, error).

description string

Optional description.

targetUrl string

Optional URL to link to.

context string

Status context (e.g., "ci/ando").

Returns

Task<bool>