Documentation
¶
Overview ¶
Package github is the little of GitHub's REST API that mcloud needs: read files, and commit several file changes at once to a branch.
Index ¶
- Variables
- func Token() (string, error)
- type Change
- type Client
- func (c *Client) Commit(ctx context.Context, repo Repo, branch, message string, ...) (string, error)
- func (c *Client) Dispatch(ctx context.Context, repo Repo, workflow, ref string) error
- func (c *Client) Exists(ctx context.Context, repo Repo, ref, p string) (bool, error)
- func (c *Client) File(ctx context.Context, repo Repo, ref, file string) ([]byte, error)
- func (c *Client) Head(ctx context.Context, repo Repo, branch string) (string, error)
- func (c *Client) RepoExists(ctx context.Context, repo Repo) (bool, error)
- func (c *Client) Run(ctx context.Context, repo Repo, id int64) (*Run, error)
- func (c *Client) RunsFor(ctx context.Context, repo Repo, sha string) ([]Run, error)
- type Reader
- type Repo
- type Run
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned for a missing repo, branch or file.
Functions ¶
Types ¶
type Client ¶
type Client struct {
BaseURL string // https://api.github.com
Token string
HTTP *http.Client
}
func (*Client) Commit ¶
func (c *Client) Commit(ctx context.Context, repo Repo, branch, message string, plan func(Reader) ([]Change, error)) (string, error)
Commit builds one commit on branch from the changes plan returns, and moves the branch to it. If the branch moves in the meantime, it starts over from the new head, so plan must be safe to call more than once. A plan that returns no changes makes no commit. Returns the new commit's SHA.
func (*Client) RepoExists ¶
RepoExists reports whether the token can see the repo.
type Run ¶
type Run struct {
ID int64 `json:"id"`
Name string `json:"name"`
Status string `json:"status"` // queued, in_progress, completed, ...
Conclusion string `json:"conclusion"` // success, failure, cancelled, ...
HTMLURL string `json:"html_url"`
Event string `json:"event"`
}
Run is a GitHub Actions workflow run.