github

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound        = errors.New("github account not found")
	ErrUnsupportedAccountType = errors.New("unsupported github account type")
)

Functions

func ErrorStatus

func ErrorStatus(err error) (int, bool)

ErrorStatus returns the HTTP status carried by a GitHub API error.

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError reports whether GitHub rejected the request because of a primary or secondary rate limit.

func LabelsMatch

func LabelsMatch(jobLabels, required []string) bool

func RateLimitRetryAfter

func RateLimitRetryAfter(err error) (string, bool)

RateLimitRetryAfter returns GitHub's Retry-After header for a classified rate-limit response.

func VerifyWebhookSignature

func VerifyWebhookSignature(secret string, body []byte, signature string) bool

Types

type Account

type Account struct {
	ID        int64  `json:"id"`
	Type      string `json:"type"`
	Login     string `json:"login"`
	Name      string `json:"name,omitempty"`
	AvatarURL string `json:"avatar_url,omitempty"`
}

type AppAuth

type AppAuth struct {
	AppID          int64
	InstallationID int64
	PrivateKeyFile string
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewAppClient

func NewAppClient(baseURL string, auth AppAuth, httpClient *http.Client) (*Client, error)

func NewBasicAuthClient

func NewBasicAuthClient(baseURL, username, password string, httpClient *http.Client) *Client

func NewClient

func NewClient(baseURL string, httpClient *http.Client) *Client

func NewTokenClient

func NewTokenClient(baseURL, token string, httpClient *http.Client) *Client

func (*Client) CreateRegistrationToken

func (c *Client) CreateRegistrationToken(ctx context.Context, repositoryFullName, runnerGroup string) (RegistrationToken, error)

func (*Client) DownloadWorkflowJobLogs

func (c *Client) DownloadWorkflowJobLogs(ctx context.Context, repositoryFullName string, jobID int64) ([]byte, string, error)

func (*Client) DownloadWorkflowRunLogs

func (c *Client) DownloadWorkflowRunLogs(ctx context.Context, repositoryFullName string, runID int64) ([]byte, string, error)

func (*Client) GetAccount

func (c *Client) GetAccount(ctx context.Context, login string) (Account, error)

func (*Client) GetInstallation

func (c *Client) GetInstallation(ctx context.Context, installationID int64) (Installation, error)

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, repositoryFullName string, number int64) (Issue, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, repositoryFullName string, number int64) (PullRequest, error)

func (*Client) GetWorkflowJob

func (c *Client) GetWorkflowJob(ctx context.Context, repositoryFullName string, jobID int64) (WorkflowJob, error)

func (*Client) ListInstallationRepositories

func (c *Client) ListInstallationRepositories(ctx context.Context, installationID int64) ([]string, error)

func (*Client) ListRunners

func (c *Client) ListRunners(ctx context.Context, repositoryFullName, runnerGroup string) ([]Runner, error)

func (*Client) ListUserInstallationRepositories

func (c *Client) ListUserInstallationRepositories(ctx context.Context, token string, installationID int64) ([]string, error)

ListUserInstallationRepositories lists repositories accessible to both the user token and installation.

func (*Client) ListUserInstallations

func (c *Client) ListUserInstallations(ctx context.Context, token string) ([]Installation, error)

func (*Client) ListUserOrganizationMemberships

func (c *Client) ListUserOrganizationMemberships(ctx context.Context, token string) ([]OrganizationMembership, error)

func (*Client) ListWorkflowRunJobs

func (c *Client) ListWorkflowRunJobs(ctx context.Context, repositoryFullName string, runID int64) ([]WorkflowJob, error)

func (*Client) RemoveRunner

func (c *Client) RemoveRunner(ctx context.Context, repositoryFullName, runnerGroup string, runnerID int64) error

func (*Client) RemoveRunnerByName

func (c *Client) RemoveRunnerByName(ctx context.Context, repositoryFullName, runnerGroup, runnerName string) (bool, error)

func (*Client) RunnerURL

func (c *Client) RunnerURL(repositoryFullName, runnerGroup string) (string, error)

type Installation

type Installation struct {
	ID            int64    `json:"id"`
	AccountID     int64    `json:"account_id,omitempty"`
	AccountType   string   `json:"account_type,omitempty"`
	AccountLogin  string   `json:"account_login,omitempty"`
	AccountName   string   `json:"account_name,omitempty"`
	AccountAvatar string   `json:"account_avatar,omitempty"`
	Repositories  []string `json:"repositories"`
}

type InstallationRef

type InstallationRef struct {
	ID int64 `json:"id"`
}

type Issue

type Issue struct {
	Number int64  `json:"number"`
	Title  string `json:"title"`
}

type Labels

type Labels []string

func (*Labels) UnmarshalJSON

func (l *Labels) UnmarshalJSON(data []byte) error

type OrganizationMembership

type OrganizationMembership struct {
	OrganizationID    int64
	OrganizationLogin string
	State             string
	Role              string
}

type PullRequest

type PullRequest struct {
	Number int64  `json:"number"`
	Title  string `json:"title"`
}

type RegistrationToken

type RegistrationToken struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
}

type Repository

type Repository struct {
	FullName string `json:"full_name"`
	Name     string `json:"name"`
}

type Runner

type Runner struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
	Busy   bool   `json:"busy"`
}

type WorkflowJob

type WorkflowJob struct {
	ID           int64  `json:"id"`
	Name         string `json:"name"`
	Status       string `json:"status"`
	Conclusion   string `json:"conclusion"`
	RunnerName   string `json:"runner_name"`
	WorkflowName string `json:"workflow_name"`
	HeadBranch   string `json:"head_branch"`
	Labels       Labels `json:"labels"`
}

type WorkflowJobEvent

type WorkflowJobEvent struct {
	Action       string          `json:"action"`
	WorkflowJob  WorkflowJob     `json:"workflow_job"`
	Repository   Repository      `json:"repository"`
	WorkflowRun  WorkflowRun     `json:"workflow_run"`
	Installation InstallationRef `json:"installation"`
}

type WorkflowRun

type WorkflowRun struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	HeadBranch string `json:"head_branch"`
}

type WorkflowRunEvent

type WorkflowRunEvent struct {
	Action       string          `json:"action"`
	WorkflowRun  WorkflowRun     `json:"workflow_run"`
	Repository   Repository      `json:"repository"`
	Installation InstallationRef `json:"installation"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL