Initial import with modified Dockerfile for env-based config generation

This commit is contained in:
2026-06-22 11:56:10 +03:00
parent 28fa7537ac
commit 6bf27aa40e
25 changed files with 3228 additions and 0 deletions
+146
View File
@@ -0,0 +1,146 @@
package webhook
import "time"
// GiteaEventType represents the type of Gitea webhook event
type GiteaEventType string
const (
EventPullRequest GiteaEventType = "pull_request"
EventPullRequestReview GiteaEventType = "pull_request_review"
EventPullRequestComment GiteaEventType = "pull_request_comment"
EventIssues GiteaEventType = "issues"
EventIssueComment GiteaEventType = "issue_comment"
)
// GiteaUser represents a Gitea user in webhook payloads
type GiteaUser struct {
ID int64 `json:"id"`
Login string `json:"login"`
FullName string `json:"full_name"`
Email string `json:"email"`
Username string `json:"username"`
}
// Repository represents a Gitea repository
type Repository struct {
ID int64 `json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
HTMLURL string `json:"html_url"`
}
// PullRequest represents a Gitea pull request
type PullRequest struct {
ID int64 `json:"id"`
Number int64 `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
HTMLURL string `json:"html_url"`
User GiteaUser `json:"user"`
Assignees []GiteaUser `json:"assignees"`
RequestedReviewers []GiteaUser `json:"requested_reviewers"`
Merged bool `json:"merged"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Issue represents a Gitea issue
type Issue struct {
ID int64 `json:"id"`
Number int64 `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
HTMLURL string `json:"html_url"`
User GiteaUser `json:"user"`
Assignees []GiteaUser `json:"assignees"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Comment represents a comment on PR or Issue
type Comment struct {
ID int64 `json:"id"`
Body string `json:"body"`
HTMLURL string `json:"html_url"`
User GiteaUser `json:"user"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Review represents a PR review
type Review struct {
ID int64 `json:"id"`
Body string `json:"body"`
State string `json:"state"` // APPROVED, CHANGES_REQUESTED, COMMENT
HTMLURL string `json:"html_url"`
User GiteaUser `json:"user"`
SubmittedAt time.Time `json:"submitted_at"`
}
// Commit represents a Git commit in webhook payloads
type Commit struct {
ID string `json:"id"` // SHA
Message string `json:"message"`
URL string `json:"url"`
Author GitUser `json:"author"`
Committer GitUser `json:"committer"`
Timestamp time.Time `json:"timestamp"`
}
// GitUser represents a git author/committer (different from GiteaUser)
type GitUser struct {
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
}
// PullRequestEvent is the payload for pull_request webhooks
type PullRequestEvent struct {
Action string `json:"action"` // opened, closed, reopened, edited, assigned, unassigned, review_requested, synchronize, etc.
Number int64 `json:"number"`
PullRequest PullRequest `json:"pull_request"`
Repository Repository `json:"repository"`
Sender GiteaUser `json:"sender"`
RequestedReviewers []GiteaUser `json:"requested_reviewers"`
RequestedReviewer *GiteaUser `json:"requested_reviewer"` // Present on review_requested action (singular)
Assignee *GiteaUser `json:"assignee"` // Present on assigned/unassigned action
Commits []Commit `json:"commits"` // Present on synchronize action
}
// PullRequestReviewEvent is the payload for pull_request_review webhooks
type PullRequestReviewEvent struct {
Action string `json:"action"` // submitted
Review Review `json:"review"`
PullRequest PullRequest `json:"pull_request"`
Repository Repository `json:"repository"`
Sender GiteaUser `json:"sender"`
}
// PullRequestCommentEvent is the payload for pull_request_comment webhooks
type PullRequestCommentEvent struct {
Action string `json:"action"` // created, edited, deleted
Comment Comment `json:"comment"`
PullRequest PullRequest `json:"pull_request"`
Repository Repository `json:"repository"`
Sender GiteaUser `json:"sender"`
}
// IssueEvent is the payload for issues webhooks
type IssueEvent struct {
Action string `json:"action"` // opened, closed, reopened, edited, assigned, unassigned, etc.
Issue Issue `json:"issue"`
Repository Repository `json:"repository"`
Sender GiteaUser `json:"sender"`
}
// IssueCommentEvent is the payload for issue_comment webhooks
type IssueCommentEvent struct {
Action string `json:"action"` // created, edited, deleted
Comment Comment `json:"comment"`
Issue Issue `json:"issue"`
Repository Repository `json:"repository"`
Sender GiteaUser `json:"sender"`
}