gh

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GHlistInstallations     = listInstallations
	GHlistAppsInstalledRepo = listAppsInstalledRepo
)

function pointers (for testing)

View Source
var (
	// ErrNotFound is error for not found
	ErrNotFound = fmt.Errorf("not found")
)

Functions

func CheckSignature

func CheckSignature(installationID int64) error

CheckSignature check trust installation id from event.

func ConcatLabels added in v1.16.0

func ConcatLabels(checkEventJSON string) (string, error)

ConcatLabels concat labels from check event JSON

func DivideScope added in v1.6.1

func DivideScope(scope string) (string, string)

DivideScope divide scope to owner and repo

func ExistGitHubRepository

func ExistGitHubRepository(scope string, accessToken string) error

ExistGitHubRepository check exist of GitHub repository

func ExistGitHubRunner added in v1.9.2

func ExistGitHubRunner(ctx context.Context, client *github.Client, owner, repo, runnerName string) (*github.Runner, error)

ExistGitHubRunner check exist registered of GitHub runner

func ExistGitHubRunnerWithRunner added in v1.10.7

func ExistGitHubRunnerWithRunner(runners []*github.Runner, runnerName string) (*github.Runner, error)

ExistGitHubRunnerWithRunner check exist registered of GitHub runner from a list of runner

func ExistRunnerReleases added in v1.10.10

func ExistRunnerReleases(runnerVersion string) error

ExistRunnerReleases check exist of runner file

func ExtractRunsOnLabels added in v1.12.0

func ExtractRunsOnLabels(in []byte) ([]string, error)

ExtractRunsOnLabels extract labels from github.WorkflowJobEvent

func GenerateGitHubAppsToken added in v1.7.0

func GenerateGitHubAppsToken(ctx context.Context, clientApps *github.Client, installationID int64, scope string) (string, *time.Time, error)

GenerateGitHubAppsToken generate token of GitHub Apps using private key clientApps needs to response of `NewClientGitHubApps()`

func GetInstallationByID added in v1.18.2

func GetInstallationByID(ctx context.Context, installationID int64) (*github.Installation, error)

GetInstallationByID returns installation from cache by ID

func GetLatestRunnerVersion added in v1.13.0

func GetLatestRunnerVersion(ctx context.Context, scope string) (string, error)

GetLatestRunnerVersion get a latest version of actions/runner

func GetRateLimitLimit added in v1.10.5

func GetRateLimitLimit() map[string]int

GetRateLimitLimit get a list of rate limit key: scope, value: remain

func GetRateLimitRemain added in v1.10.5

func GetRateLimitRemain() map[string]int

GetRateLimitRemain get a list of rate limit remaining key: scope, value: remain

func GetRunnerRegistrationToken added in v1.10.6

func GetRunnerRegistrationToken(ctx context.Context, installationID int64, scope string) (string, error)

GetRunnerRegistrationToken get token for register runner clientInstallation needs to response of `NewClientInstallation()`

func InitializeCache added in v1.10.6

func InitializeCache(appID int64, appPEM []byte) error

InitializeCache create a cache

func IsInstalledGitHubApp added in v1.7.0

func IsInstalledGitHubApp(ctx context.Context, inputScope string) (int64, error)

IsInstalledGitHubApp check installed GitHub Apps in gheDomain + inputScope clientApps needs to response of `NewClientGitHubApps()`

func IsRequestedMyshoesLabel added in v1.18.5

func IsRequestedMyshoesLabel(labels []string) bool

IsRequestedMyshoesLabel checks if the job has appropriate labels for myshoes

func ListRunners added in v1.6.1

func ListRunners(ctx context.Context, client *github.Client, owner, repo string) ([]*github.Runner, error)

ListRunners get runners that registered repository or org

func ListWorkflowJobByRunID added in v1.18.0

func ListWorkflowJobByRunID(ctx context.Context, client *github.Client, owner, repo string, runID int64) ([]*github.WorkflowJob, error)

ListWorkflowJobByRunID get workflow job by run ID

func ListWorkflowRunsNewest added in v1.18.0

func ListWorkflowRunsNewest(ctx context.Context, client *github.Client, owner, repo string, limit int) ([]*github.WorkflowRun, error)

ListWorkflowRunsNewest get workflow runs that registered in the last (%d: limit) runs

func NewClient

func NewClient(token string) (*github.Client, error)

NewClient create a client of GitHub

func NewClientGitHubApps added in v1.9.7

func NewClientGitHubApps() (*github.Client, error)

NewClientGitHubApps create a client of GitHub using Private Key from GitHub Apps header is "Authorization: Bearer YOUR_JWT" docs: https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app

func NewClientInstallation added in v1.9.7

func NewClientInstallation(installationID int64) (*github.Client, error)

NewClientInstallation create a client of GitHub using installation ID from GitHub Apps header is "Authorization: token YOUR_INSTALLATION_ACCESS_TOKEN" docs: https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-an-installation

func PurgeInstallationCache added in v1.18.0

func PurgeInstallationCache(ctx context.Context) error

PurgeInstallationCache purges the cache of installations

Types

type ErrIsNotInstalledGitHubApps added in v1.18.0

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

func (*ErrIsNotInstalledGitHubApps) Error added in v1.18.0

func (*ErrIsNotInstalledGitHubApps) Unwrap added in v1.18.0

func (e *ErrIsNotInstalledGitHubApps) Unwrap() error

type Scope

type Scope int

Scope is scope for auto-scaling target

const (
	Unknown Scope = iota
	Repository
	Organization
)

Scope values

func DetectScope

func DetectScope(scope string) Scope

DetectScope detect a scope (repo or org)

func (Scope) String

func (s Scope) String() string

String is fmt.Stringer interface

Jump to

Keyboard shortcuts

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