github

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChannelMembers added in v1.1.0

func ChannelMembers(ctx workflow.Context, pr PullRequest) []string

ChannelMembers returns a list of opted-in Slack user IDs who are PR authors/reviewers/followers. The output is guaranteed to be sorted, without repetitions, and not contain (unresolved) teams or bots.

func ImpersonateUserInMsg added in v1.1.0

func ImpersonateUserInMsg(ctx workflow.Context, url, channelID string, user User, msg string, diff []byte) error

func ImpersonateUserInReply added in v1.1.0

func ImpersonateUserInReply(ctx workflow.Context, url, parentURL string, user User, msg string, diff []byte) error

func ImpersonationToMention added in v1.1.0

func ImpersonationToMention(msg string) string

ImpersonationToMention converts a message that was meant to be used in ImpersonateUserInMsg or ImpersonateUserInReply into a message that can be used in MentionUserInMsg or MentionUserInReply, by adjusting the prefix.

This is potentially relevant only for file and inline comments: if the message includes a file (i.e. contains a Slack file permalink), we can't impersonate the user, because the Slack API won't allow us to update or delete the message later.

func InitPRData added in v1.1.0

func InitPRData(ctx workflow.Context, event PullRequestEvent, prChannelID, slackAlertsChannel string)

InitPRData saves the initial state of a new PR: snapshots of PR metadata, and a 2-way ID mapping for syncs between GitHub and Slack. If there are errors, they are logged but ignored, as we can try to recreate the data later.

func LoginsToSlackIDs added in v1.1.0

func LoginsToSlackIDs(ctx workflow.Context, logins []string) []string

func MentionUserInMsg added in v1.1.0

func MentionUserInMsg(ctx workflow.Context, channelID string, user User, msg string)

func MentionUserInReply added in v1.1.0

func MentionUserInReply(ctx workflow.Context, parentURL string, user User, msg string) error

func ReviewerMentions added in v1.1.0

func ReviewerMentions(ctx workflow.Context, action, role string, reviewers []User) string

ReviewerMentions returns a Slack message mentioning 1 or more added or removed reviewers.

func SetChannelBookmarks added in v1.1.0

func SetChannelBookmarks(ctx workflow.Context, channelID, prURL string, pr PullRequest)

func SlackDisplayName added in v1.1.0

func SlackDisplayName(ctx workflow.Context, user User) string

SlackDisplayName returns the Slack display name corresponding to the given GitHub user, linked to their Slack profile if possible. We use this instead of users.GitHubIDToSlackRef in cases where we want to mention the user without actually spamming them with echoes of their own actions.

func UpdateChannelBookmarks added in v1.1.0

func UpdateChannelBookmarks(ctx workflow.Context, pr *PullRequest, issue *Issue, channelID string)

UpdateChannelBookmarks updates the bookmarks in the PR's Slack channel, based on the latest PR event. This is a deferred call that doesn't return an error, because handling the event itself is more important.

Types

type ChangeBase added in v0.2.0

type ChangeBase struct {
	Ref ChangeFrom `json:"ref"`
	SHA ChangeFrom `json:"sha"`
}

type ChangeFrom added in v0.2.0

type ChangeFrom struct {
	From string `json:"from"`
}

type Changes

type Changes struct {
	Title *ChangeFrom `json:"title,omitempty"`
	Body  *ChangeFrom `json:"body,omitempty"`
	Base  *ChangeBase `json:"base,omitempty"`
}

type Installation

type Installation struct {
	ID     int64  `json:"id"`
	NodeID string `json:"node_id"`
}

type Issue

type Issue = github.Issue

type IssueComment added in v1.1.0

type IssueComment = github.IssueComment

type IssueCommentEvent

type IssueCommentEvent struct {
	Action  string       `json:"action"`
	Issue   Issue        `json:"issue"`
	Comment IssueComment `json:"comment"`
	Sender  User         `json:"sender"`

	Changes *Changes `json:"changes,omitempty"`
}

IssueCommentEvent is based on: https://docs.github.com/en/webhooks/webhook-events-and-payloads#issue_comment

type Organization

type Organization struct {
	ID     int64  `json:"id"`
	NodeID string `json:"node_id"`
	Login  string `json:"login"`
}

type PullComment added in v1.1.0

type PullComment = github.PullComment

type PullRequest

type PullRequest = github.PullRequest

type PullRequestEvent

type PullRequestEvent struct {
	Action      string      `json:"action"`
	Number      int         `json:"number"`
	PullRequest PullRequest `json:"pull_request"`
	Sender      User        `json:"sender"`

	Assignee          *User    `json:"assignee,omitempty"`
	RequestedReviewer *User    `json:"requested_reviewer,omitempty"`
	RequestedTeam     *Team    `json:"requested_team,omitempty"`
	Changes           *Changes `json:"changes,omitempty"`
	Before            *string  `json:"before,omitempty"`
	After             *string  `json:"after,omitempty"`
}

PullRequestEvent is based on: https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request

type PullRequestReviewCommentEvent

type PullRequestReviewCommentEvent struct {
	Action      string      `json:"action"`
	Comment     PullComment `json:"comment"`
	PullRequest PullRequest `json:"pull_request"`
	Sender      User        `json:"sender"`

	Changes *Changes `json:"changes,omitempty"`
}

PullRequestReviewCommentEvent is based on: https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request_review_comment

type PullRequestReviewEvent

type PullRequestReviewEvent struct {
	Action      string      `json:"action"`
	Review      Review      `json:"review"`
	PullRequest PullRequest `json:"pull_request"`
	Sender      User        `json:"sender"`

	Changes *Changes `json:"changes,omitempty"`
}

PullRequestReviewEvent is based on: https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request_review

type PullRequestReviewThreadEvent

type PullRequestReviewThreadEvent struct {
	Action      string      `json:"action"`
	Thread      Thread      `json:"thread"`
	PullRequest PullRequest `json:"pull_request"`
	Sender      User        `json:"sender"`

	UpdatedAt time.Time `json:"updated_at,omitzero"`
}

PullRequestReviewThreadEvent is based on: https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request_review_thread

type Review

type Review = github.Review

type Team

type Team = github.Team

type Thread

type Thread struct {
	NodeID   string        `json:"node_id"`
	Comments []PullComment `json:"comments"`
}

Thread is based on: https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request_review_thread

type User

type User = github.User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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