events

package
v0.0.0-...-d6af952 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

WIP

Index

Constants

This section is empty.

Variables

View Source
var SupportedEvents = map[string]func(bytes []byte) (discordgo.MessageSend, error){
	"branch_protection_rule":      branchProtectionRuleFn,
	"check_suite":                 checkSuiteFn,
	"create":                      createFn,
	"issues":                      issuesFn,
	"issue_comment":               issueCommentFn,
	"pull_request":                pullRequestFn,
	"pull_request_review_comment": pullRequestReviewCommentFn,
	"push":                        pushFn,
	"star":                        starFn,
	"status":                      statusFn,
	"release":                     releaseFn,
	"commit_comment":              commitCommentFn,
	"deployment":                  deploymentFn,
	"deployment_status":           deploymentStatusFn,
	"discussion":                  discussionFn,
	"discussion_comment":          discussionCommentFn,
	"workflow_run":                workflowRunFn,
	"dependabot_alert":            dependabotAlertFn,
	"delete":                      deleteFn,
	"workflow_job":                workflowJobFn,
	"check_run":                   checkRunFn,
	"public":                      publicFn,
	"watch":                       watchFn,
	"repository":                  repositoryFn,
	"team":                        teamFn,
	"fork":                        forkFn,
	"page_build":                  pageBuildFn,
}

Functions

This section is empty.

Types

type BranchProtectionRuleEvent

type BranchProtectionRuleEvent struct {
	Action  string         `json:"action"`
	Repo    Repository     `json:"repository"`
	Sender  User           `json:"sender"`
	Rule    bprRule        `json:"rule"`
	Changes map[string]any `json:"changes"`
}

type CheckRunEvent

type CheckRunEvent struct {
	Action   string     `json:"action"`
	Repo     Repository `json:"repository"`
	Sender   User       `json:"sender"`
	CheckRun struct {
		Name       string    `json:"name"`
		HTMLURL    string    `json:"html_url"`
		StartedAt  time.Time `json:"started_at"`
		Status     string    `json:"status"`
		DetailsURL string    `json:"details_url"`
		Conclusion string    `json:"conclusion"`
		HeadSHA    string    `json:"head_sha"`
	} `json:"check_run"`
}

type CheckSuiteEvent

type CheckSuiteEvent struct {
	Action     string     `json:"action"`
	Repo       Repository `json:"repository"`
	Sender     User       `json:"sender"`
	CheckSuite struct {
		ID         int    `json:"id"`
		After      string `json:"after,omitempty"`
		HeadBranch string `json:"head_branch,omitempty"`
		HeadSHA    string `json:"head_sha,omitempty"`
		Status     string `json:"status,omitempty"`
		Conclusion string `json:"conclusion,omitempty"`
		URL        string `json:"url,omitempty"`
		Before     string `json:"before,omitempty"`
		HeadCommit struct {
			ID        string `json:"id,omitempty"`
			TreeID    string `json:"tree_id,omitempty"`
			Message   string `json:"message,omitempty"`
			Timestamp string `json:"timestamp,omitempty"`
			Author    struct {
				Name     string `json:"name,omitempty"`
				Email    string `json:"email,omitempty"`
				Username string `json:"username,omitempty"`
			} `json:"author,omitempty"`
			Committer struct {
				Name     string `json:"name,omitempty"`
				Email    string `json:"email,omitempty"`
				Username string `json:"username,omitempty"`
			} `json:"committer,omitempty"`
		} `json:"head_commit,omitempty"`
	} `json:"check_suite"`
}

type CommitCommentEvent

type CommitCommentEvent struct {
	Action  string     `json:"action"`
	Repo    Repository `json:"repository"`
	Sender  User       `json:"sender"`
	Comment struct {
		Body     string `json:"body"`
		HTMLURL  string `json:"html_url"`
		User     User   `json:"user"`
		CommitID string `json:"commit_id"`
	}
}

type CreateEvent

type CreateEvent struct {
	Repo         Repository `json:"repository"`
	Sender       User       `json:"sender"`
	Ref          string     `json:"ref"`
	RefType      string     `json:"ref_type"`
	MasterBranch string     `json:"master_branch"`
	PusherType   string     `json:"pusher_type"`
}

type DeleteEvent

type DeleteEvent struct {
	Repo       Repository `json:"repository"`
	Sender     User       `json:"sender"`
	Ref        string     `json:"ref"`
	RefType    string     `json:"ref_type"`
	PusherType string     `json:"pusher_type"`
}

type DependabotAlertEvent

type DependabotAlertEvent struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
	Alert  struct {
		HTMLURL    string `json:"html_url"`
		State      string `json:"state"`
		Dependency struct {
			Package struct {
				Name      string `json:"name"`
				Ecosystem string `json:"ecosystem"`
			} `json:"package"`
			ManifestPath string `json:"manifest_path"`
			Scope        string `json:"scope"`
		} `json:"dependency"`
		SecurityAdvisory struct {
			Severity        string `json:"severity"`
			GHSAID          string `json:"ghsa_id"`
			CVEID           string `json:"cve_id"`
			Summary         string `json:"summary"`
			Description     string `json:"description"`
			Vulnerabilities []struct {
				Severity               string `json:"severity"`
				VulnerableVersionRange string `json:"vulnerable_version_range"`
				FirstPatchedVersion    struct {
					Identifier string `json:"identifier"`
				} `json:"first_patched_version"`
			} `json:"vulnerabilities"`
		} `json:"security_advisory"`
		DismissedReason string `json:"dismissed_reason"`
		DismissedBy     User   `json:"dismissed_by"`
	} `json:"alert"`
}

type DeploymentEvent

type DeploymentEvent struct {
	Action     string     `json:"action"`
	Repo       Repository `json:"repository"`
	Sender     User       `json:"sender"`
	Deployment struct {
		Creator               User      `json:"creator"`
		CreatedAt             time.Time `json:"created_at"`
		SHA                   string    `json:"sha"`
		Description           string    `json:"description"`
		OriginalEnvironment   string    `json:"original_environment"`
		Environment           string    `json:"environment"`
		ProductionEnvironment bool      `json:"production_environment"`
		TransientEnvironment  bool      `json:"transient_environment"`
		StatusesUrl           string    `json:"statuses_url"`
	} `json:"deployment"`
}

type DeploymentStatusEvent

type DeploymentStatusEvent struct {
	Action           string     `json:"action"`
	Repo             Repository `json:"repository"`
	Sender           User       `json:"sender"`
	DeploymentStatus struct {
		Creator        User      `json:"creator"`
		CreatedAt      time.Time `json:"created_at"`
		Description    string    `json:"description"`
		EnvironmentURL string    `json:"environment_url"`
		LogURL         string    `json:"log_url"`
		TargetURL      string    `json:"target_url"`
	} `json:"deployment_status"`
	Deployment struct {
		Task        string `json:"task"`
		Description string `json:"description"`
		SHA         string `json:"sha"`
	}
}

type DiscussionCommentEvent

type DiscussionCommentEvent struct {
	Action  string     `json:"action"`     // The type of action for the event
	Repo    Repository `json:"repository"` // The repository where this event was created
	Sender  User       `json:"sender"`     // The user who sent/created the event
	Comment struct {
		Author  User      `json:"user"`       // Author of the comment
		Content string    `json:"body"`       // The content of the comment
		Created time.Time `json:"created_at"` // Comment creation
		Url     string    `json:"html_url"`   // Url to the comment
	} `json:"comment"`
	Discussion struct {
		Title    string `json:"title"` // The title of the origin discussion
		Category struct {
			Name        string `json:"name"`          // Name of the discussion category
			Answerable  bool   `json:"is_answerable"` // If the discussion can have a valid answer
			Description string `json:"description"`   // The description of the discussion category
		} `json:"category"`
		Date time.Time `json:"created_at"` // Date the discussion was created
		Url  string    `json:"html_url"`   // URL to the discussion
	} `json:"discussion"`
}

type DiscussionEvent

type DiscussionEvent struct {
	Action string     `json:"action"`     // The type of action for the event
	Repo   Repository `json:"repository"` // The repository where this event was created
	Sender User       `json:"sender"`     // The user who sent/created the event
	Label  struct {
		Name        string `json:"name"`        // Name of the discussion label
		Default     bool   `json:"default"`     // Is the label our a default label
		Description string `json:"description"` // Description of the label
	} `json:"label"`
	Discussion struct {
		Title            string `json:"title"`              // The title of the origin discussion
		Author           User   `json:"user"`               // The user who originally posted the discussion/answer
		Created          string `json:"answer_chosen_at"`   // The date the answer was chosen at
		AnswerSubmitter  User   `json:"answer_chosen_by"`   // The user who marked the answer as correct
		ActiveLockReason string `json:"active_lock_reason"` // Reason for the discussion being locked (no comments allowed)
		AnswerHtmlUrl    string `json:"answer_html_url"`    // URL To the answer/comment
		AnswerRespBody   string `json:"body"`               // Body/content of the answer
		Category         struct {
			Name        string `json:"name"`          // Name of the discussion category
			Answerable  bool   `json:"is_answerable"` // If the discussion can have a valid answer
			Description string `json:"description"`   // The description of the discussion category
		} `json:"category"`
		DiscussionDate time.Time `json:"created_at"` // Date the discussion was created
		DiscussionURL  string    `json:"html_url"`   // URL to the discussion
	} `json:"discussion"`
}

type ForkEvent

type ForkEvent struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Forkee Repository `json:"forkee"`
	Sender User       `json:"sender"`
}

type Issue

type Issue struct {
	ID      int    `json:"id"`
	Number  int    `json:"number"`
	State   string `json:"state"`
	Title   string `json:"title"`
	Body    string `json:"body"`
	HTMLURL string `json:"html_url"`
	URL     string `json:"url"`
	User    User   `json:"user"`
}

type IssueCommentEvent

type IssueCommentEvent struct {
	Action  string     `json:"action"`
	Repo    Repository `json:"repository"`
	Sender  User       `json:"sender"`
	Issue   Issue      `json:"issue"`
	Comment struct {
		Body    string `json:"body"`
		HTMLURL string `json:"html_url"`
		User    User   `json:"user"`
	} `json:"comment"`
}

type IssuesEvent

type IssuesEvent struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
	Issue  Issue      `json:"issue"`
}

type KeyValue

type KeyValue struct {
	Key   string
	Value any
}

Auxillary but useful for large lists of data

func (KeyValue) String

func (k KeyValue) String() string

func (KeyValue) StringMD

func (k KeyValue) StringMD() string

type PageBuildEvent

type PageBuildEvent struct {
	Build struct {
		Commit    string    `json:"commit"`
		CreatedAt time.Time `json:"created_at"`
		Duration  int       `json:"duration"`
		Error     struct {
			Message string `json:"message"`
		} `json:"error"`
		Status string `json:"status"`
	} `json:"build"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
}

type PublicEvent

type PublicEvent struct {
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
}

type PullRequest

type PullRequest struct {
	ID      int               `json:"id"`
	Number  int               `json:"number"`
	State   string            `json:"state"`
	Locked  bool              `json:"locked"`
	Title   string            `json:"title"`
	Body    string            `json:"body"`
	HTMLURL string            `json:"html_url"`
	URL     string            `json:"url"`
	User    User              `json:"user"`
	Base    PullRequestCommit `json:"base"`
	Head    PullRequestCommit `json:"head"`
}

type PullRequestCommit

type PullRequestCommit struct {
	Repo       Repository `json:"repo"`
	ID         int        `json:"id"`
	Number     int        `json:"number"`
	State      string     `json:"state"`
	Title      string     `json:"title"`
	Body       string     `json:"body"`
	HTMLURL    string     `json:"html_url"`
	URL        string     `json:"url"`
	Ref        string     `json:"ref"`
	Label      string     `json:"label"`
	User       User       `json:"user"`
	CommitsURL string     `json:"commits_url"`
}

type PullRequestEvent

type PullRequestEvent struct {
	Action      string      `json:"action"`
	Repo        Repository  `json:"repository"`
	Sender      User        `json:"sender"`
	PullRequest PullRequest `json:"pull_request"`
}

type PullRequestReviewCommentEvent

type PullRequestReviewCommentEvent struct {
	Action      string      `json:"action"`
	Repo        Repository  `json:"repository"`
	Sender      User        `json:"sender"`
	PullRequest PullRequest `json:"pull_request"`
	Comment     struct {
		Body    string `json:"body"`
		HTMLURL string `json:"html_url"`
		User    User   `json:"user"`
	} `json:"comment"`
}

type PushEvent

type PushEvent struct {
	Commits []struct {
		ID        string `json:"id"`
		Message   string `json:"message"`
		Timestamp string `json:"timestamp"`
		URL       string `json:"url"`
		Author    struct {
			Name     string `json:"name"`
			Email    string `json:"email"`
			Username string `json:"username"`
		} `json:"author"`
	} `json:"commits"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
	Pusher struct {
		Name        string `json:"name"`
		Description string `json:"description"`
	} `json:"pusher,omitempty"`
	Ref     string `json:"ref"`
	BaseRef string `json:"base_ref"`
}

type ReleaseEvent

type ReleaseEvent struct {
	Action  string     `json:"action"`
	Repo    Repository `json:"repository"`
	Sender  User       `json:"sender"`
	Release struct {
		HTMLUrl string `json:"html_url"`
		Body    string `json:"body"`
		TagName string `json:"tag_name"`
	} `json:"release"`
}

type RepoWrapper

type RepoWrapper struct {
	Repo   Repository `json:"repository"`
	Action string     `json:"action"`
}

Core struct for defining a basic github event

type RepositiryVulnerabilityAlert

type RepositiryVulnerabilityAlert struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
}

type Repository

type Repository struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	FullName    string `json:"full_name"`
	Description string `json:"description"`
	URL         string `json:"url"`
	Owner       User   `json:"owner"`
	HTMLURL     string `json:"html_url"`
	CommitsURL  string `json:"commits_url"`
	Private     bool   `json:"private"`
}

func (Repository) Commit

func (r Repository) Commit(id string) string

Commit returns the commit URL for the given commit ID.

func (Repository) Visibility

func (r Repository) Visibility() string

type RepositoryEvent

type RepositoryEvent struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
}

type StarEvent

type StarEvent struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
}

type StatusEvent

type StatusEvent struct {
	Repo        Repository `json:"repository"`
	Sender      User       `json:"sender"`
	State       string     `json:"state"`
	Description string     `json:"description"`
	TargetURL   string     `json:"target_url"`
	Context     string     `json:"context"`
	Commit      struct {
		HTMLURL string `json:"html_url"`
		SHA     string `json:"sha"`
		Author  struct {
			Login   string `json:"login"`
			HTMLURL string `json:"html_url"` // user
		} `json:"author"`
		Commit struct {
			ID      string `json:"id"`
			Message string `json:"message"`
		} `json:"commit"`
	} `json:"commit"`
}

type TeamEvent

type TeamEvent struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
	Team   struct {
		Name        string `json:"name"`
		ID          int    `json:"id"`
		Slug        string `json:"slug"`
		Deleted     bool   `json:"deleted"`
		HTMLUrl     string `json:"html_url"`
		Permission  string `json:"permission"`
		Privacy     string `json:"privacy"`
		Description string `json:"description"`
	} `json:"team"`
}

type User

type User struct {
	Login            string `json:"login"`
	ID               int    `json:"id"`
	AvatarURL        string `json:"avatar_url"`
	URL              string `json:"url"`
	HTMLURL          string `json:"html_url"`
	OrganizationsURL string `json:"organizations_url"`
}

func (User) AuthorEmbed

func (u User) AuthorEmbed() *discordgo.MessageEmbedAuthor
func (u User) Link() string

type WatchEvent

type WatchEvent struct {
	Action string     `json:"action"`
	Repo   Repository `json:"repository"`
	Sender User       `json:"sender"`
}

type WorkflowJobEvent

type WorkflowJobEvent struct {
	Action      string     `json:"action"`
	Repo        Repository `json:"repository"`
	Sender      User       `json:"sender"`
	WorkflowJob struct {
		ID           int    `json:"id"`
		RunID        int    `json:"run_id"`
		WorkflowName string `json:"workflow_name"`
		HeadBranch   string `json:"head_branch"`
		RunURL       string `json:"run_url"`
		RunAttempt   int    `json:"run_attempt"`
		NodeID       string `json:"node_id"`
		HeadSHA      string `json:"head_sha"`
		URL          string `json:"url"`
		HTMLURL      string `json:"html_url"`
		Status       string `json:"status"`
		Conclusion   string `json:"conclusion"`
		StartedAt    string `json:"started_at"`
		CompletedAt  string `json:"completed_at"`
		Name         string `json:"name"`
		Steps        []struct {
			Name        string `json:"name"`
			Status      string `json:"status"`
			Conclusion  string `json:"conclusion"`
			Number      int    `json:"number"`
			StartedAt   string `json:"started_at"`
			CompletedAt string `json:"completed_at"`
		} `json:"steps"`
		CheckRunUrl     string   `json:"check_run_url"`
		Labels          []string `json:"labels"`
		RunnerID        int      `json:"runner_id"`
		RunnerName      string   `json:"runner_name"`
		RunnerGroupID   int      `json:"runner_group_id"`
		RunnerGroupName string   `json:"runner_group_name"`
	} `json:"workflow_job"`
}

type WorkflowRunEvent

type WorkflowRunEvent struct {
	Action      string     `json:"action"`
	Repo        Repository `json:"repository"`
	Sender      User       `json:"sender"`
	WorkflowRun struct {
		ID              int    `json:"id"`
		HeadBranch      string `json:"head_branch"`
		HeadSHA         string `json:"head_sha"`
		RunNumber       int    `json:"run_number"`
		Event           string `json:"event"`
		Name            string `json:"name"`
		Status          string `json:"status"`
		Conclusion      string `json:"conclusion"`
		URL             string `json:"url"`
		TriggeringActor User   `json:"triggering_actor"`
		HeadCommit      struct {
			ID        string `json:"id"`
			TreeID    string `json:"tree_id"`
			Message   string `json:"message"`
			Timestamp string `json:"timestamp"`
			Author    User   `json:"author"`
			Committer User   `json:"committer"`
		} `json:"head_commit"`
	} `json:"workflow_run"`
}

Jump to

Keyboard shortcuts

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