Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) CreateIssueComment(ctx context.Context, prID int, comment string) error
- func (c *Client) CreatePullRequest(ctx context.Context, head, base, title, body string) (*PullRequest, error)
- func (c *Client) CreateReviewComment(ctx context.Context, prID int, s *PullRequestComment) error
- func (c *Client) IssueComments(ctx context.Context, prID int) ([]IssueComment, error)
- func (c *Client) ListPullRequestFiles(ctx context.Context, prID int) ([]string, error)
- func (c *Client) OpeningPullRequest(ctx context.Context, branch string) (*PullRequest, error)
- func (c *Client) PullRequest(ctx context.Context, number int) (*PullRequest, error)
- func (c *Client) ReviewComments(ctx context.Context, prID int) ([]PullRequestComment, error)
- func (c *Client) UpdateIssueComment(ctx context.Context, id int, comment string) error
- func (c *Client) UpdateReviewComment(ctx context.Context, id int, body string) error
- type ClientOption
- type IssueComment
- type PullRequest
- type PullRequestComment
- type TriggerEvent
Constants ¶
const DefaultBaseURL = "https://api.github.com"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an implementation of the SCMClient interface for GitHub Actions.
func NewClient ¶
func NewClient(repo string, opts ...ClientOption) (*Client, error)
NewClient returns a new GitHub client for the given repository. If the GITHUB_TOKEN is set, it will be used for authentication.
func (*Client) CreateIssueComment ¶
func (*Client) CreatePullRequest ¶ added in v1.11.9
func (c *Client) CreatePullRequest(ctx context.Context, head, base, title, body string) (*PullRequest, error)
CreatePullRequest creates a new pull request.
func (*Client) CreateReviewComment ¶
func (*Client) IssueComments ¶
func (*Client) ListPullRequestFiles ¶
ListPullRequestFiles return paths of the files in the trigger event pull request.
func (*Client) OpeningPullRequest ¶
OpeningPullRequest returns the latest open pull request for the given branch.
func (*Client) PullRequest ¶ added in v1.11.9
PullRequest returns information about a pull request.
func (*Client) ReviewComments ¶
ReviewComments for the trigger event pull request.
func (*Client) UpdateIssueComment ¶
UpdateIssueComment updates issue comment with the given id.
type ClientOption ¶
ClientOption is the option when creating a new client.
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL returns a ClientOption that sets the base URL for the client.
func WithToken ¶
func WithToken(t *oauth2.Token) ClientOption
WithToken returns a ClientOption that sets the token for the client.
type IssueComment ¶
type PullRequest ¶
type PullRequestComment ¶
type TriggerEvent ¶
type TriggerEvent struct {
// Only in case of an 'issue_comment' event.
Comment struct {
Body string `mapstructure:"body"`
URL string `mapstructure:"html_url"`
} `mapstructure:"comment"`
Issue struct {
Number int `mapstructure:"number"`
URL string `mapstructure:"html_url"`
PullRequest *struct{} `mapstructure:"pull_request"` // not-nil if the issue is a pull request
} `mapstructure:"issue"`
// Only in case of a 'pull_request' event.
PullRequest struct {
Number int `mapstructure:"number"`
Body string `mapstructure:"body"`
URL string `mapstructure:"html_url"`
Head struct {
SHA string `mapstructure:"sha"`
} `mapstructure:"head"`
} `mapstructure:"pull_request"`
Repository struct {
URL string `mapstructure:"html_url"`
DefaultBranch string `mapstructure:"default_branch"`
} `mapstructure:"repository"`
}
TriggerEvent is the structure of the GitHub trigger event.
func ExtractEvent ¶
func ExtractEvent(raw map[string]any) (*TriggerEvent, error)
ExtractEvent extracts the trigger event data from the raw event.