github_helper

package module
v0.0.0-...-c7a0120 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TOKEN_TTL = int64(5)
)

Functions

func AppendToGHActionsSummary

func AppendToGHActionsSummary(summary string)

func CallGithubAPI

func CallGithubAPI(token string, method string, path string, data interface{}) (string, error)

func CommitAndPush

func CommitAndPush(repo GitHubRepo, commit GitCommit) string

func CreateTagAndPush

func CreateTagAndPush(tag GitTag)

func GenerateInstallationAccessToken

func GenerateInstallationAccessToken(token string, installationId int) (string, error)

func GenerateToken

func GenerateToken(githubAppId string, privatePem []byte) (string, error)

generate jwt token

func GetModifiedAndNewFiles

func GetModifiedAndNewFiles() ([]string, error)

func GetModifiedFiles

func GetModifiedFiles() ([]string, error)

func GetModifiedFilesFromGitDiff

func GetModifiedFilesFromGitDiff(fromStaged bool) ([]string, error)

func IsGitHubActions

func IsGitHubActions() bool

func SendToGHActionsOutput

func SendToGHActionsOutput(variable string, output string)

func SetGithubAppToken

func SetGithubAppToken(token *GitHubAppToken)

func SignJWTAppToken

func SignJWTAppToken(appId string, privatePem []byte)

func SignJWTAppTokenWithFilename

func SignJWTAppTokenWithFilename(appId string, pemFilename string)

func StageModifiedAndNewFiles

func StageModifiedAndNewFiles() error

func StageModifiedFiles

func StageModifiedFiles() error

Types

type CommitOptions

type CommitOptions struct {
	AddNewFiles        bool
	Force              bool
	RemoveDeletedFiles bool
}

type CommitParent

type CommitParent struct {
	Sha     string `json:"sha"`
	Url     string `json:"url"`
	HtmlUrl string `json:"html_url"`
}

type CommitVerification

type CommitVerification struct {
	Verified  bool   `json:"verified"`
	Reason    string `json:"reason"`
	Signature string `json:"signature"`
	Payload   string `json:"payload"`
}

type FileInfo

type FileInfo struct {
	Permissions string
	Number      string
	Owner       string
	Group       string
	Size        string
	Month       string
	Day         string
	Time        string
	Name        string
}

func ListFiles

func ListFiles(dir *string) ([]FileInfo, error)

type GitCommit

type GitCommit struct {
	HeadBranch *string
	Branch     string
	Coauthors  *[]GitUser
	OnBehalfOf *GitHubOrg
	Message    string
	Options    CommitOptions
}

type GitFile

type GitFile struct {
	FileName   string
	WasDeleted bool
	Sha        *string
}

func UploadFilesToGitHubBlob

func UploadFilesToGitHubBlob(files []string) ([]GitFile, error)

type GitHubAppToken

type GitHubAppToken struct {
	Repo  GitHubRepo `json:"repo"`
	Token string     `json:"token"`
}

func GenerateInstallationAppToken

func GenerateInstallationAppToken(repo GitHubRepo) GitHubAppToken

type GitHubOrg

type GitHubOrg struct {
	Name  string
	Slug  string
	Email string
}

type GitHubRepo

type GitHubRepo struct {
	Owner string `json:"owner"`
	Repo  string `json:"repo"`
}

type GitHubUser

type GitHubUser struct {
	Date  string `json:"date"`
	Email string `json:"email"`
	Name  string `json:"name"`
}

type GitTag

type GitTag struct {
	TagName   string
	Message   string
	CommitSha string
}

type GitUser

type GitUser struct {
	Name  string
	Email string
}

type GithubAccount

type GithubAccount struct {
	Login             string `json:"login"`
	Id                int    `json:"id"`
	NodeID            string `json:"node_id"`
	AvatarUrl         string `json:"avatar_url"`
	GravatarId        string `json:"gravatar_id"`
	Url               string `json:"url"`
	HtmlUrl           string `json:"html_url"`
	FollowersUrl      string `json:"followers_url"`
	FollowingUrl      string `json:"following_url"`
	GistsUrl          string `json:"gists_url"`
	StarredUrl        string `json:"starred_url"`
	SubscriptionsUrl  string `json:"subscriptions_url"`
	OrganizationsUrl  string `json:"organizations_url"`
	ReposUrl          string `json:"repos_url"`
	EventsUrl         string `json:"events_url"`
	ReceivedEventsUrl string `json:"received_events_url"`
	Type              string `json:"type"`
	SiteAdmin         bool   `json:"site_admin"`
}

type GithubAppInstallationResponse

type GithubAppInstallationResponse struct {
	Id                     int           `json:"id"`
	Account                GithubAccount `json:"account"`
	RepositorySelection    string        `json:"repository_selection"`
	AccessTokenUrl         string        `json:"access_tokens_url"`
	HtmlUrl                string        `json:"html_url"`
	AppId                  int           `json:"app_id"`
	TargetId               int           `json:"target_id"`
	TargetType             string        `json:"target_type"`
	Permissions            Permissions   `json:"permissions"`
	Events                 []string      `json:"events"`
	CreatedAt              time.Time     `json:"created_at"`
	UpdatedAt              time.Time     `json:"updated_at"`
	SingleFileName         string        `json:"single_file_name"`
	HasMultipleSingleFiles bool          `json:"has_multiple_single_files"`
	SingleFilePaths        []string      `json:"single_file_paths"`
	AppSlug                string        `json:"app_slug"`
	SuspendedAt            *time.Time    `json:"suspended_at"`
	SuspendedBy            *string       `json:"suspended_by"`
}

func GetAppInstallationDetails

func GetAppInstallationDetails(jwt string, repo GitHubRepo) (GithubAppInstallationResponse, error)

type GithubBlobRequest

type GithubBlobRequest struct {
	Content  string `json:"content"`  // The content of the blob.
	Encoding string `json:"encoding"` // The encoding used for content. Currently, "utf-8" and "base64" are supported.
}

type GithubBlobResponse

type GithubBlobResponse struct {
	Url string `json:"url"` // ulr of the blob
	Sha string `json:"sha"` // sha of the blob
}

func CreateBlob

func CreateBlob(blob GithubBlobRequest) (GithubBlobResponse, error)

func UploadFileToGitHubBlob

func UploadFileToGitHubBlob(filename string) (GithubBlobResponse, error)

type GithubCommitRequest

type GithubCommitRequest struct {
	Message string   `json:"message"`
	Parents []string `json:"parents"`
	Tree    string   `json:"tree"`
}

type GithubCommitResponse

type GithubCommitResponse struct {
	Sha          string             `json:"sha"`
	NodeId       string             `json:"node_id"`
	Url          string             `json:"url"`
	Author       GitHubUser         `json:"author"`
	Committer    GitHubUser         `json:"committer"`
	Message      string             `json:"message"`
	Tree         TreeItem           `json:"tree"`
	Parents      []CommitParent     `json:"parents"`
	Verification CommitVerification `json:"verification"`
	HtmlUrl      string             `json:"html_url"`
}

func CreateCommit

func CreateCommit(commit GithubCommitRequest) (GithubCommitResponse, error)

type GithubRefRequest

type GithubRefRequest struct {
	Ref   string `json:"ref,omitempty"`
	Sha   string `json:"sha"`
	Force bool   `json:"force,omitempty"`
}

type GithubRefResponse

type GithubRefResponse struct {
	Ref    string    `json:"ref"`
	NodeId string    `json:"node_id"`
	Url    string    `json:"url"`
	Object RefObject `json:"object"`
}

func CreateReference

func CreateReference(request GithubRefRequest) (GithubRefResponse, error)

func GetReference

func GetReference(ref string) (GithubRefResponse, error)

func UpdateReference

func UpdateReference(request GithubRefRequest, ref string, createBranch bool) (GithubRefResponse, error)

type GithubTagRequest

type GithubTagRequest struct {
	Tag     string        `json:"tag"`
	Message string        `json:"message"`
	Object  string        `json:"object"`
	Type    string        `json:"type"`
	Tagger  *GithubTagger `json:"tagger,omitempty"`
}

type GithubTagResponse

type GithubTagResponse struct {
	NodeID       string             `json:"node_id"`
	Tag          string             `json:"tag"`
	Sha          string             `json:"sha"`
	Url          string             `json:"url"`
	Message      string             `json:"message"`
	Tagger       GithubTagger       `json:"tagger,omitempty"`
	Object       RefObject          `json:"object"`
	Verification CommitVerification `json:"verification"`
}

func CreateTag

func CreateTag(tag GithubTagRequest) (GithubTagResponse, error)

type GithubTagger

type GithubTagger struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date,omitempty"`
}

type GithubTreeRequest

type GithubTreeRequest struct {
	BaseTree string     `json:"base_tree"`
	Tree     []TreeItem `json:"tree"`
}

type GithubTreeResponse

type GithubTreeResponse struct {
	Sha       string     `json:"sha"`
	Url       string     `json:"url"`
	Truncated bool       `json:"truncated"`
	Tree      []TreeItem `json:"tree"`
}

func CreateTree

func CreateTree(tree GithubTreeRequest) (GithubTreeResponse, error)

type Permissions

type Permissions struct {
	Actions  string `json:"actions"`
	Contents string `json:"contents"`
	Metadata string `json:"metadata"`
	Packages string `json:"packages"`
	Checks   string `json:"checks"`
}

type RefObject

type RefObject struct {
	Sha  string `json:"sha"`
	Type string `json:"type"`
	Url  string `json:"url"`
}

type TokenInfo

type TokenInfo struct {
	Token               string      `json:"token"`
	ExpiresAt           time.Time   `json:"expires_at"`
	Permissions         Permissions `json:"permissions"`
	RepositorySelection string      `json:"repository_selection"`
}

type TreeItem

type TreeItem struct {
	Path    string  `json:"path"` // file referenced in the tree.
	Mode    string  `json:"mode"` // Can be one of: 100644, 100755, 040000, 160000, 120000
	Type    string  `json:"type"` // Can be one of: blob, tree, or commit.
	Sha     *string `json:"sha"`
	Content string  `json:"content,omitempty"`
	Size    int     `json:"size,omitempty"`
	Url     string  `json:"url,omitempty"`
}

Jump to

Keyboard shortcuts

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