Documentation
¶
Index ¶
- func ParseRepo(url string) (owner, repo string, err error)
- type Asset
- type CheckRun
- type Client
- func (c *Client) AddAssignees(ctx context.Context, owner, repo string, number int, users []string) error
- func (c *Client) AddLabels(ctx context.Context, owner, repo string, number int, labels []string) error
- func (c *Client) CancelRun(ctx context.Context, owner, repo string, runID int64) error
- func (c *Client) CommentPR(ctx context.Context, owner, repo string, number int, body string) (string, error)
- func (c *Client) CreateIssue(ctx context.Context, owner, repo, title, body string) (int, string, error)
- func (c *Client) CreateLabel(ctx context.Context, owner, repo, name, color, description string) error
- func (c *Client) CreatePR(ctx context.Context, owner, repo, title, body, head, base string) (int, string, error)
- func (c *Client) CreateRelease(ctx context.Context, owner, repo, tag, name, body string, ...) (Release, error)
- func (c *Client) CreateRepo(ctx context.Context, name, description string, private bool) (string, error)
- func (c *Client) DefaultBranch(ctx context.Context, owner, repo string) (string, error)
- func (c *Client) DeleteAsset(ctx context.Context, owner, repo string, assetID int64) error
- func (c *Client) DeleteIssueComment(ctx context.Context, owner, repo string, commentID int64) error
- func (c *Client) DeleteLabel(ctx context.Context, owner, repo, name string) error
- func (c *Client) DeleteRelease(ctx context.Context, owner, repo string, id int64) error
- func (c *Client) DownloadAsset(ctx context.Context, owner, repo string, assetID int64) ([]byte, error)
- func (c *Client) EditIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) error
- func (c *Client) EditLabel(ctx context.Context, owner, repo, name, newName, color, description string) error
- func (c *Client) EditRelease(ctx context.Context, owner, repo string, id int64, name, body string, ...) (Release, error)
- func (c *Client) GenerateReleaseNotes(ctx context.Context, owner, repo, tag string) (name, body string, err error)
- func (c *Client) GetRun(ctx context.Context, owner, repo string, runID int64) (WorkflowRun, error)
- func (c *Client) IssueListGraphQL(ctx context.Context, owner, repo, state string) ([]IssueListItem, error)
- func (c *Client) JobLogs(ctx context.Context, owner, repo string, jobID int64) (JobLog, error)
- func (c *Client) ListAssets(ctx context.Context, owner, repo string, releaseID int64) ([]Asset, error)
- func (c *Client) ListDispatchableWorkflows(ctx context.Context, owner, repo string) ([]DispatchableWorkflow, error)
- func (c *Client) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]IssueComment, error)
- func (c *Client) ListIssues(ctx context.Context, owner, repo, state string) ([]Issue, error)
- func (c *Client) ListLabels(ctx context.Context, owner, repo string) ([]Label, error)
- func (c *Client) ListMilestones(ctx context.Context, owner, repo, state string) ([]Milestone, error)
- func (c *Client) ListPRs(ctx context.Context, owner, repo, state string) ([]PR, error)
- func (c *Client) ListReleases(ctx context.Context, owner, repo string) ([]Release, error)
- func (c *Client) ListRequestedReviewers(ctx context.Context, owner, repo string, number int) ([]Reviewer, error)
- func (c *Client) ListReviewComments(ctx context.Context, owner, repo string, number int) ([]ExistingComment, error)
- func (c *Client) ListReviews(ctx context.Context, owner, repo string, number int) ([]Review, error)
- func (c *Client) ListRunJobs(ctx context.Context, owner, repo string, runID int64) ([]Job, error)
- func (c *Client) ListRuns(ctx context.Context, owner, repo string, limit int) ([]WorkflowRun, error)
- func (c *Client) ListWorkflows(ctx context.Context, owner, repo string) ([]Workflow, error)
- func (c *Client) LockConversation(ctx context.Context, owner, repo string, number int, reason string) error
- func (c *Client) MergePR(ctx context.Context, owner, repo string, number int, method string) (string, error)
- func (c *Client) PRChecks(ctx context.Context, owner, repo string, number int) ([]CheckRun, error)
- func (c *Client) PRDetailGraphQL(ctx context.Context, owner, repo string, number int) (*PRDetail, error)
- func (c *Client) PRDiff(ctx context.Context, owner, repo string, number int) ([]gitops.FileDiff, error)
- func (c *Client) PRListGraphQL(ctx context.Context, owner, repo, state string) ([]PRListItem, error)
- func (c *Client) RateLimit(ctx context.Context) (remaining, limit int, err error)
- func (c *Client) RemoveAssignees(ctx context.Context, owner, repo string, number int, users []string) error
- func (c *Client) RemoveLabel(ctx context.Context, owner, repo string, number int, label string) error
- func (c *Client) RemoveReviewer(ctx context.Context, owner, repo string, number int, login string) error
- func (c *Client) ReplyToReviewComment(ctx context.Context, owner, repo string, number int, commentID int64, ...) error
- func (c *Client) RequestReviewers(ctx context.Context, owner, repo string, number int, logins []string) error
- func (c *Client) RerunFailed(ctx context.Context, owner, repo string, runID int64) error
- func (c *Client) RerunRun(ctx context.Context, owner, repo string, runID int64) error
- func (c *Client) ResolveThread(ctx context.Context, threadID string) error
- func (c *Client) RunJobGraph(ctx context.Context, owner, repo string, runID int64) ([]JobNode, error)
- func (c *Client) SetIssueState(ctx context.Context, owner, repo string, number int, state string) error
- func (c *Client) SetLabels(ctx context.Context, owner, repo string, number int, labels []string) error
- func (c *Client) SetMilestone(ctx context.Context, owner, repo string, number, milestone int) error
- func (c *Client) SetPRState(ctx context.Context, owner, repo string, number int, state string) error
- func (c *Client) SubmitReview(ctx context.Context, owner, repo string, number int, event, body string, ...) error
- func (c *Client) TriggerDispatch(ctx context.Context, owner, repo, workflowFile, ref string, ...) error
- func (c *Client) UnlockConversation(ctx context.Context, owner, repo string, number int) error
- func (c *Client) UnresolveThread(ctx context.Context, threadID string) error
- func (c *Client) UploadAsset(ctx context.Context, owner, repo string, releaseID int64, name string, ...) (Asset, error)
- func (c *Client) Whoami(ctx context.Context) (string, error)
- type DispatchInput
- type DispatchableWorkflow
- type ExistingComment
- type Issue
- type IssueComment
- type IssueListItem
- type Job
- type JobLog
- type JobNode
- type Label
- type Milestone
- type PR
- type PRDetail
- type PRDetailCheck
- type PRDetailReview
- type PRDetailThread
- type PRDetailThreadComment
- type PRListItem
- type Release
- type Review
- type ReviewComment
- type Reviewer
- type Step
- type StepLog
- type Workflow
- type WorkflowRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CheckRun ¶
type CheckRun struct {
Name string
Status string // queued, in_progress, completed
Conclusion string // success, failure, neutral, cancelled, ... (empty until completed)
}
CheckRun is a trimmed view of one CI check on a commit.
type Client ¶
Client wraps the go-github client plus the resolved owner/repo.
func New ¶
New builds an authenticated client. The token is resolved from, in order:
- the GITHUB_TOKEN process environment variable
- a .env file (walking up from the working directory)
- the persisted user environment variable (Windows), via `gh auth token`
The first non-empty source wins.
func (*Client) AddAssignees ¶
func (c *Client) AddAssignees(ctx context.Context, owner, repo string, number int, users []string) error
AddAssignees adds users as assignees on an issue or pull request.
func (*Client) AddLabels ¶
func (c *Client) AddLabels(ctx context.Context, owner, repo string, number int, labels []string) error
AddLabels adds labels to an issue or PR (PRs are issues here).
func (*Client) CancelRun ¶
CancelRun cancels an in-progress workflow run. Requires a token with the workflow scope.
func (*Client) CommentPR ¶
func (c *Client) CommentPR(ctx context.Context, owner, repo string, number int, body string) (string, error)
CommentPR posts a comment on a PR or issue (they share the comment endpoint).
func (*Client) CreateIssue ¶
func (c *Client) CreateIssue(ctx context.Context, owner, repo, title, body string) (int, string, error)
CreateIssue opens an issue. Returns the new issue number and its HTML URL.
func (*Client) CreateLabel ¶
func (c *Client) CreateLabel(ctx context.Context, owner, repo, name, color, description string) error
CreateLabel creates a new label definition (color = 6-hex, no #).
func (*Client) CreatePR ¶
func (c *Client) CreatePR(ctx context.Context, owner, repo, title, body, head, base string) (int, string, error)
CreatePR opens a pull request from head into base. head is a branch name (e.g. "feature/x"); base is usually the default branch (e.g. "live"). Returns the new PR number and its HTML URL.
func (*Client) CreateRelease ¶
func (c *Client) CreateRelease(ctx context.Context, owner, repo, tag, name, body string, draft, prerelease bool) (Release, error)
CreateRelease creates a release on the given tag.
func (*Client) CreateRepo ¶
func (c *Client) CreateRepo(ctx context.Context, name, description string, private bool) (string, error)
CreateRepo creates a new repository under the authenticated user's account. Passing "" as the org means "create it on my own account."
func (*Client) DefaultBranch ¶
DefaultBranch returns the repository's default branch (e.g. "main"/"live"), used as the sensible base when opening a pull request.
func (*Client) DeleteAsset ¶
DeleteAsset removes an asset from a release.
func (*Client) DeleteIssueComment ¶
DeleteIssueComment deletes an issue/PR comment by its ID.
func (*Client) DeleteLabel ¶
DeleteLabel removes a label definition from the repo.
func (*Client) DeleteRelease ¶
DeleteRelease removes a release by ID (does NOT delete the underlying tag).
func (*Client) DownloadAsset ¶
func (c *Client) DownloadAsset(ctx context.Context, owner, repo string, assetID int64) ([]byte, error)
DownloadAsset returns the raw bytes of a release asset.
func (*Client) EditIssueComment ¶
func (c *Client) EditIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) error
EditIssueComment edits the body of an existing issue/PR comment by its ID.
func (*Client) EditLabel ¶
func (c *Client) EditLabel(ctx context.Context, owner, repo, name, newName, color, description string) error
EditLabel updates an existing label. newName can equal name to keep it.
func (*Client) EditRelease ¶
func (c *Client) EditRelease(ctx context.Context, owner, repo string, id int64, name, body string, draft, prerelease bool) (Release, error)
EditRelease updates an existing release by ID.
func (*Client) GenerateReleaseNotes ¶
func (c *Client) GenerateReleaseNotes(ctx context.Context, owner, repo, tag string) (name, body string, err error)
GenerateReleaseNotes asks GitHub to auto-generate notes for a tag.
func (*Client) IssueListGraphQL ¶
func (c *Client) IssueListGraphQL(ctx context.Context, owner, repo, state string) ([]IssueListItem, error)
IssueListGraphQL fetches issues (by state) with labels + assignees in one query. state: "open"/"closed"/"all".
func (*Client) JobLogs ¶
JobLogs downloads a single job's log (completed runs only) and returns it, best-effort split per step using GitHub's "##[group]" markers. On any parse uncertainty the Raw whole-job log is always available as a fallback.
func (*Client) ListAssets ¶
func (c *Client) ListAssets(ctx context.Context, owner, repo string, releaseID int64) ([]Asset, error)
ListAssets returns the assets attached to a release.
func (*Client) ListDispatchableWorkflows ¶
func (c *Client) ListDispatchableWorkflows(ctx context.Context, owner, repo string) ([]DispatchableWorkflow, error)
ListDispatchableWorkflows returns workflows that declare a workflow_dispatch trigger, with their inputs parsed from the workflow YAML. This drives a dynamic dispatch form (render a field per declared input).
func (*Client) ListIssueComments ¶
func (c *Client) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]IssueComment, error)
ListIssueComments returns the general (non-line) comment stream on a PR.
func (*Client) ListIssues ¶
ListIssues returns issues for owner/repo — with PRs filtered out.
func (*Client) ListLabels ¶
ListLabels returns all label definitions in the repo.
func (*Client) ListMilestones ¶
func (c *Client) ListMilestones(ctx context.Context, owner, repo, state string) ([]Milestone, error)
ListMilestones returns the repository's milestones (open by default; pass "all" or "closed" for others).
func (*Client) ListPRs ¶
ListPRs returns pull requests for owner/repo in the given state ("open", "closed", or "all").
func (*Client) ListReleases ¶
ListReleases returns the repo's releases, newest first.
func (*Client) ListRequestedReviewers ¶
func (c *Client) ListRequestedReviewers(ctx context.Context, owner, repo string, number int) ([]Reviewer, error)
ListRequestedReviewers returns users whose review has been requested but not yet submitted.
func (*Client) ListReviewComments ¶
func (c *Client) ListReviewComments(ctx context.Context, owner, repo string, number int) ([]ExistingComment, error)
ListReviewComments returns the line-anchored review comments on a PR.
func (*Client) ListReviews ¶
ListReviews returns the submitted reviews on a PR, oldest first.
func (*Client) ListRunJobs ¶
ListRunJobs returns the jobs (with steps) for a run.
func (*Client) ListRuns ¶
func (c *Client) ListRuns(ctx context.Context, owner, repo string, limit int) ([]WorkflowRun, error)
ListRuns returns recent workflow runs for the repo, newest first.
func (*Client) ListWorkflows ¶
ListWorkflows returns the repo's workflow definitions.
func (*Client) LockConversation ¶
func (c *Client) LockConversation(ctx context.Context, owner, repo string, number int, reason string) error
LockConversation locks an issue or PR conversation. reason may be "off-topic", "too heated", "resolved", "spam", or "" for no reason.
func (*Client) MergePR ¶
func (c *Client) MergePR(ctx context.Context, owner, repo string, number int, method string) (string, error)
MergePR merges a pull request. method is "merge", "squash", or "rebase". Returns the merge commit SHA on success.
func (*Client) PRChecks ¶
PRChecks returns the CI check runs for a PR's head commit — this is how you see whether GitHub Actions (your own CI) passed on the PR.
func (*Client) PRDetailGraphQL ¶
func (c *Client) PRDetailGraphQL(ctx context.Context, owner, repo string, number int) (*PRDetail, error)
PRDetailGraphQL fetches everything about a PR in a single GraphQL query.
func (*Client) PRDiff ¶
func (c *Client) PRDiff(ctx context.Context, owner, repo string, number int) ([]gitops.FileDiff, error)
PRDiff fetches the PR's unified diff and parses it into the same []gitops.FileDiff that DiffView already renders.
func (*Client) PRListGraphQL ¶
func (c *Client) PRListGraphQL(ctx context.Context, owner, repo, state string) ([]PRListItem, error)
PRListGraphQL fetches PRs (by state) with per-PR review decision + check rollup in a single query. state: "OPEN", "CLOSED", "MERGED" (GraphQL enums).
func (*Client) RateLimit ¶
RateLimit reports remaining core API calls — useful to watch while you learn, since unauthenticated requests are capped at 60/hour.
func (*Client) RemoveAssignees ¶
func (c *Client) RemoveAssignees(ctx context.Context, owner, repo string, number int, users []string) error
RemoveAssignees removes users from the assignees of an issue or pull request.
func (*Client) RemoveLabel ¶
func (c *Client) RemoveLabel(ctx context.Context, owner, repo string, number int, label string) error
RemoveLabel removes a single label from an issue or PR.
func (*Client) RemoveReviewer ¶
func (c *Client) RemoveReviewer(ctx context.Context, owner, repo string, number int, login string) error
RemoveReviewer withdraws a review request from a user.
func (*Client) ReplyToReviewComment ¶
func (c *Client) ReplyToReviewComment(ctx context.Context, owner, repo string, number int, commentID int64, body string) error
ReplyToReviewComment posts a reply to an existing review comment thread.
func (*Client) RequestReviewers ¶
func (c *Client) RequestReviewers(ctx context.Context, owner, repo string, number int, logins []string) error
RequestReviewers asks the given users to review the PR.
func (*Client) RerunFailed ¶
RerunFailed re-runs only the failed jobs of a completed run.
func (*Client) ResolveThread ¶
ResolveThread marks a review thread resolved (GraphQL-only; no REST equivalent).
func (*Client) RunJobGraph ¶
func (c *Client) RunJobGraph(ctx context.Context, owner, repo string, runID int64) ([]JobNode, error)
RunJobGraph returns the job dependency graph for a run's workflow, parsed from the workflow YAML (jobs.<name>.needs). The GUI overlays live job status onto this to draw a flowchart. Falls back to a flat (no-edges) graph if YAML parse fails or needs aren't declared.
func (*Client) SetIssueState ¶
func (c *Client) SetIssueState(ctx context.Context, owner, repo string, number int, state string) error
SetIssueState closes or reopens an issue. state is "closed" or "open".
func (*Client) SetLabels ¶
func (c *Client) SetLabels(ctx context.Context, owner, repo string, number int, labels []string) error
SetLabels replaces all labels on an issue or PR with the given set.
func (*Client) SetMilestone ¶
SetMilestone assigns an issue/PR to a milestone by number; pass 0 to clear it.
func (*Client) SetPRState ¶
func (c *Client) SetPRState(ctx context.Context, owner, repo string, number int, state string) error
SetPRState closes or reopens a pull request. state is "closed" or "open".
func (*Client) SubmitReview ¶
func (c *Client) SubmitReview(ctx context.Context, owner, repo string, number int, event, body string, comments []ReviewComment) error
SubmitReview posts a whole-PR review. event is "APPROVE", "REQUEST_CHANGES", or "COMMENT". body is optional for APPROVE but required by GitHub for REQUEST_CHANGES and COMMENT.
func (*Client) TriggerDispatch ¶
func (c *Client) TriggerDispatch(ctx context.Context, owner, repo, workflowFile, ref string, inputs map[string]interface{}) error
TriggerDispatch fires a workflow_dispatch event on the given workflow file (e.g. "release.yml") for a ref (branch/tag), with input values.
func (*Client) UnlockConversation ¶
UnlockConversation unlocks a previously locked issue or PR conversation.
func (*Client) UnresolveThread ¶
UnresolveThread reopens a resolved review thread.
type DispatchInput ¶
type DispatchInput struct {
Name string
Description string
Required bool
Default string
Type string // string, boolean, choice, number, environment
Options []string // for type=choice
}
DispatchInput describes one workflow_dispatch input the workflow defines.
type DispatchableWorkflow ¶
type DispatchableWorkflow struct {
ID int64
Name string
Path string
Inputs []DispatchInput
}
DispatchableWorkflow is a workflow that has a workflow_dispatch trigger, with its declared inputs (parsed from the workflow YAML).
type ExistingComment ¶
type ExistingComment struct {
ID int64
Path string
Line int
Author string
Body string
InReplyTo int64
}
ExistingComment is a review comment already posted on the PR, anchored to a file + line. ReplyToID (0 if top-level) links a reply to its parent thread.
type Issue ¶
type Issue struct {
Number int
Title string
Author string
State string
When time.Time
Labels []string
}
Issue is a trimmed issue view.
type IssueComment ¶
IssueComment is a general (not line-anchored) PR comment from the issue stream.
type IssueListItem ¶
type IssueListItem struct {
Number int
Title string
Author string
State string
Labels []string
Assignees []string
}
IssueListItem is an issue with its labels + assignees, fetched via GraphQL's issues connection (which — unlike the REST issues endpoint — returns ONLY issues, never PRs, so no client-side PR filtering is needed).
type JobLog ¶
type JobLog struct {
JobName string
Steps []StepLog
Raw string // full log; shown when per-step split isn't reliable
}
JobLog is a job's captured log, split (best-effort) into per-step sections.
type JobNode ¶
JobNode is a job in the workflow's dependency graph: its name and the jobs it needs (must complete first). Parsed from the workflow YAML.
type PR ¶
type PR struct {
Number int
Title string
Author string
State string
When time.Time
Draft bool
Labels []string
}
PR is a trimmed pull-request view.
type PRDetail ¶
type PRDetail struct {
Number int
Title string
State string
Body string
Author string
Labels []string
Assignees []string
Reviews []PRDetailReview
Threads []PRDetailThread
Checks []PRDetailCheck
}
PRDetail is the aggregated PR view fetched in ONE GraphQL query — the whole point of the GraphQL path: reviews + review threads + checks + labels + assignees together, instead of many REST round-trips.
type PRDetailCheck ¶
PRDetailCheck is a CI check on a PR's head commit (name + status + conclusion).
type PRDetailReview ¶
PRDetailReview is a review on a PR (author + state + body) from the aggregated GraphQL query.
type PRDetailThread ¶
type PRDetailThread struct {
ID string
Path string
Line int
IsResolved bool
Comments []PRDetailThreadComment
}
PRDetailThread is a review-comment thread with its resolve state and GraphQL node ID (needed for the resolve/unresolve mutations — REST has no equivalent).
type PRDetailThreadComment ¶
PRDetailThreadComment is one comment within a review thread.
type PRListItem ¶
type PRListItem struct {
Number int
Title string
Author string
State string
Draft bool
Labels []string
ReviewDecision string // APPROVED / CHANGES_REQUESTED / REVIEW_REQUIRED / ""
ChecksTotal int
ChecksPassed int
ChecksFailed int
ChecksPending int
}
PRListItem is a PR in a list view WITH its rollup status (labels, review decision, CI check summary) — fetched in ONE GraphQL query for the whole list, instead of REST's N+1 (list + per-PR checks/reviews).
type Release ¶
type Release struct {
ID int64
TagName string
Name string
Body string
Draft bool
Prerelease bool
Immutable bool
URL string
}
Release is a trimmed GitHub release view.
type Review ¶
type Review struct {
ID int64
Author string
State string // APPROVED, CHANGES_REQUESTED, COMMENTED, DISMISSED, PENDING
Body string
}
Review is a trimmed PR review (a whole-PR verdict).
type ReviewComment ¶
ReviewComment is a pending line comment to attach to a submitted review. Path is the file path; Line is the line number in the file's new version; Body is the comment text.
type Reviewer ¶
type Reviewer struct {
Login string
}
Reviewer is a requested (not-yet-submitted) reviewer on a PR.
type WorkflowRun ¶
type WorkflowRun struct {
ID int64
Name string
WorkflowID int64
WorkflowName string // for grouping (falls back to Name)
Status string // queued, in_progress, completed
Conclusion string // success, failure, cancelled, "" while running
Branch string
Event string
Number int
CreatedAt string
Duration string // human-readable run duration ("1m23s"), "" if not finished/started
URL string
}
WorkflowRun is one execution of a workflow.