Documentation
¶
Overview ¶
Package docspreview owns the docs-preview screenshots branch and sticky comment mutation policy used by GitHub Actions.
Index ¶
- Constants
- func BuildRewriteCommit(ctx context.Context, client TreeWriter, repo Repository, kept []TreeEntry, ...) (string, error)
- func Cleanup(ctx context.Context, options CleanupOptions) error
- func IsSameRepoPR(event Event, repo Repository) bool
- func IsStaleRunDir(path string, now time.Time, maxAge time.Duration) bool
- func Prune(ctx context.Context, options PruneOptions) error
- func Publish(ctx context.Context, options PublishOptions) error
- type BlobWriter
- type BranchClient
- type BranchResult
- type BranchTip
- type CleanupClient
- type CleanupOptions
- type Comment
- type CommentClient
- type Commit
- type CommitToBranchOptions
- type Event
- type EventOwner
- type EventRepository
- type GitHubHTTPClient
- func (client *GitHubHTTPClient) CreateBlob(ctx context.Context, owner, repo string, content, encoding string) (string, error)
- func (client *GitHubHTTPClient) CreateComment(ctx context.Context, owner, repo string, issueNumber int, body string) error
- func (client *GitHubHTTPClient) CreateCommit(ctx context.Context, owner, repo string, message, tree string, ...) (string, error)
- func (client *GitHubHTTPClient) CreateRef(ctx context.Context, owner, repo, ref, sha string) error
- func (client *GitHubHTTPClient) CreateTree(ctx context.Context, owner, repo string, entries []TreeEntry, baseTree string) (string, error)
- func (client *GitHubHTTPClient) GetCommit(ctx context.Context, owner, repo, sha string) (Commit, error)
- func (client *GitHubHTTPClient) GetRef(ctx context.Context, owner, repo, ref string) (Ref, error)
- func (client *GitHubHTTPClient) GetTree(ctx context.Context, owner, repo, sha string, recursive bool) (Tree, error)
- func (client *GitHubHTTPClient) ListComments(ctx context.Context, owner, repo string, issueNumber int) ([]Comment, error)
- func (client *GitHubHTTPClient) UpdateComment(ctx context.Context, owner, repo string, commentID int64, body string) error
- func (client *GitHubHTTPClient) UpdateRef(ctx context.Context, owner, repo, ref, sha string) error
- type Logger
- type PreviewEntry
- type PreviewManifest
- type PruneClient
- type PruneOptions
- type PublishClient
- type PublishOptions
- type PullBaseRef
- type PullRef
- type PullRepository
- type PullRequest
- type Ref
- type Repository
- type StatusError
- type Tree
- type TreeEntry
- type TreeReader
- type TreeWriter
Constants ¶
View Source
const ( ScreenshotsBranch = "screenshots" StickyMarker = "<!-- docs-preview -->" DefaultMaxAge = 30 * 24 * time.Hour // EmptyTreeSHA is git's well-known empty tree. The GitHub API rejects // createTree with an empty tree slice, so destructive rewrites that keep no // files commit this tree directly. EmptyTreeSHA = "4b825dc642cb6eb9a060e54bf8d69288fbee4904" )
Variables ¶
This section is empty.
Functions ¶
func BuildRewriteCommit ¶
func BuildRewriteCommit(ctx context.Context, client TreeWriter, repo Repository, kept []TreeEntry, parentSHA, message string) (string, error)
func IsSameRepoPR ¶
func IsSameRepoPR(event Event, repo Repository) bool
IsSameRepoPR fails closed for deleted/fork heads. Fork PR tokens are read-only even when workflow permissions request writes, and publish runs from PR-controlled code for same-repo PRs only.
Types ¶
type BlobWriter ¶
type BranchClient ¶
type BranchClient interface {
GetRef(ctx context.Context, owner, repo, ref string) (Ref, error)
CreateRef(ctx context.Context, owner, repo, ref, sha string) error
UpdateRef(ctx context.Context, owner, repo, ref, sha string) error
GetCommit(ctx context.Context, owner, repo, sha string) (Commit, error)
}
type BranchResult ¶
func CommitToBranch ¶
func CommitToBranch(ctx context.Context, options CommitToBranchOptions) (BranchResult, error)
type CleanupClient ¶
type CleanupClient interface {
BranchClient
TreeReader
TreeWriter
CommentClient
}
type CleanupOptions ¶
type CleanupOptions struct {
Client CleanupClient
Logger Logger
Repo Repository
Event Event
}
type CommentClient ¶
type CommentClient interface {
ListComments(ctx context.Context, owner, repo string, issueNumber int) ([]Comment, error)
UpdateComment(ctx context.Context, owner, repo string, commentID int64, body string) error
CreateComment(ctx context.Context, owner, repo string, issueNumber int, body string) error
}
type CommitToBranchOptions ¶
type CommitToBranchOptions struct {
Client BranchClient
Logger Logger
Repo Repository
CreateIfAbsent bool
MaxAttempts int
BuildCommit func(context.Context, *BranchTip) (string, error)
}
type Event ¶
type Event struct {
Repository EventRepository `json:"repository"`
PullRequest *PullRequest `json:"pull_request"`
}
type EventOwner ¶
type EventRepository ¶
type EventRepository struct {
FullName string `json:"full_name"`
Name string `json:"name"`
Owner EventOwner `json:"owner"`
}
type GitHubHTTPClient ¶
func (*GitHubHTTPClient) CreateBlob ¶
func (*GitHubHTTPClient) CreateComment ¶
func (*GitHubHTTPClient) CreateCommit ¶
func (*GitHubHTTPClient) CreateRef ¶
func (client *GitHubHTTPClient) CreateRef(ctx context.Context, owner, repo, ref, sha string) error
func (*GitHubHTTPClient) CreateTree ¶
func (*GitHubHTTPClient) ListComments ¶
func (*GitHubHTTPClient) UpdateComment ¶
type PreviewEntry ¶
type PreviewManifest ¶
type PreviewManifest map[string]map[string]PreviewEntry
type PruneClient ¶
type PruneClient interface {
BranchClient
TreeReader
TreeWriter
}
type PruneOptions ¶
type PruneOptions struct {
Client PruneClient
Logger Logger
Repo Repository
Now time.Time
MaxAge time.Duration
}
type PublishClient ¶
type PublishClient interface {
BranchClient
TreeWriter
BlobWriter
CommentClient
}
type PublishOptions ¶
type PullBaseRef ¶
type PullRef ¶
type PullRef struct {
Repo *PullRepository `json:"repo"`
}
type PullRepository ¶
type PullRepository struct {
FullName string `json:"full_name"`
}
type PullRequest ¶
type PullRequest struct {
Number int `json:"number"`
Head PullRef `json:"head"`
Base PullBaseRef `json:"base"`
}
type Repository ¶
func ParseRepository ¶
func ParseRepository(value string) (Repository, error)
func RepositoryFromEvent ¶
func RepositoryFromEvent(event Event) (Repository, error)
func (Repository) FullName ¶
func (repo Repository) FullName() string
type StatusError ¶
func (*StatusError) Error ¶
func (err *StatusError) Error() string
type TreeEntry ¶
type TreeEntry struct {
Path string `json:"path"`
Mode string `json:"mode"`
Type string `json:"type"`
SHA string `json:"sha"`
}
func ListBlobsOrFail ¶
func ListBlobsOrFail(ctx context.Context, client TreeReader, repo Repository, treeSHA string) ([]TreeEntry, error)
type TreeReader ¶
Click to show internal directories.
Click to hide internal directories.