github

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWorkPath = ".github-workpath"
	// https://github.com/merico-dev/dtm-scaffolding-golang/archive/refs/heads/main.zip -> 302 ->
	// https://codeload.github.com/merico-dev/dtm-scaffolding-golang/zip/refs/heads/main
	DefaultLatestCodeZipfileDownloadUrlFormat = "https://codeload.github.com/%s/%s/zip/refs/heads/main"
	DefaultLatestCodeZipfileName              = "main-latest.zip"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*Option
	*github.Client
	context.Context
}

func NewClient

func NewClient(option *Option) (*Client, error)

func (*Client) AddRepoSecret

func (c *Client) AddRepoSecret(secretKey, secretValue string) error

AddRepoSecret adds a secret to a GitHub repo.

func (*Client) AddWorkflow

func (c *Client) AddWorkflow(workflow *Workflow, branch string) error

func (*Client) CreateFile

func (c *Client) CreateFile(content []byte, filePath, targetBranch string) error

func (*Client) CreateRepo

func (c *Client) CreateRepo() error

func (*Client) DeleteRepo added in v0.3.0

func (c *Client) DeleteRepo() error

func (*Client) DeleteRepoSecret

func (c *Client) DeleteRepoSecret(secretKey string) error

DeleteRepoSecret deletes a secret in a GitHub repo.

func (*Client) DeleteWorkflow

func (c *Client) DeleteWorkflow(workflow *Workflow, branch string) error

func (*Client) DownloadAsset

func (c *Client) DownloadAsset(tagName, assetName string) error

func (*Client) DownloadLatestCodeAsZipFile

func (c *Client) DownloadLatestCodeAsZipFile() error

func (*Client) FetchRemoteContent added in v0.3.0

func (c *Client) FetchRemoteContent(wsFiles []string) ([]string, map[string]error, error)

func (*Client) GetLastCommit added in v0.2.0

func (c *Client) GetLastCommit() (*github.RepositoryCommit, error)

func (*Client) GetRepoDescription added in v0.2.0

func (c *Client) GetRepoDescription() (*github.Repository, error)

func (*Client) GetWorkflowPath added in v0.2.0

func (c *Client) GetWorkflowPath() (string, error)

func (*Client) MergePullRequest added in v0.2.0

func (c *Client) MergePullRequest(number int, mergeMethod MergeMethod) error

func (*Client) NewBranch added in v0.2.0

func (c *Client) NewBranch(baseBranch, newBranch string) error

func (*Client) NewPullRequest added in v0.2.0

func (c *Client) NewPullRequest(fromBranch, toBranch string) (int, error)

func (*Client) RepoSecretExists

func (c *Client) RepoSecretExists(secretKey string) (bool, error)

RepoSecretExists detects if a secret exists in a GitHub repo.

func (*Client) VerifyWorkflows

func (c *Client) VerifyWorkflows(workflows []*Workflow) (map[string]error, error)

VerifyWorkflows get the workflows with names "wf1.yml", "wf2.yml", then: If all workflows is ok => return ({"wf1.yml":nil, "wf2.yml:nil}, nil) If some error occurred => return (nil, error) If wf1.yml is not found => return ({"wf1.yml":error("not found"), "wf2.yml:nil},nil)

type MergeMethod added in v0.2.0

type MergeMethod string
const (
	MergeMethodSquash MergeMethod = "squash"
	MergeMethodMerge  MergeMethod = "merge"
	MergeMethodRebase MergeMethod = "rebase"
)

type Option

type Option struct {
	Owner    string
	Repo     string
	NeedAuth bool
	WorkPath string
}

type Workflow

type Workflow struct {
	CommitMessage    string
	WorkflowFileName string
	WorkflowContent  string
}

Workflow is the struct for a GitHub Actions Workflow.

Jump to

Keyboard shortcuts

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