mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	Convert GitHub event on actions and fix some pull_request events. (#23037)
Follow #22680 Partially Fix #22958, on pull_request, `opened`, `reopened`, `synchronize` supported, `edited` hasn't been supported yet because Gitea doesn't trigger that events. --------- Co-authored-by: yp05327 <576951401@qq.com>
This commit is contained in:
		
							
								
								
									
										41
									
								
								modules/actions/github.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								modules/actions/github.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| // Copyright 2023 The Gitea Authors. All rights reserved. | ||||
| // SPDX-License-Identifier: MIT | ||||
|  | ||||
| package actions | ||||
|  | ||||
| import ( | ||||
| 	webhook_module "code.gitea.io/gitea/modules/webhook" | ||||
|  | ||||
| 	"github.com/nektos/act/pkg/jobparser" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	githubEventPullRequest              = "pull_request" | ||||
| 	githubEventPullRequestTarget        = "pull_request_target" | ||||
| 	githubEventPullRequestReviewComment = "pull_request_review_comment" | ||||
| 	githubEventPullRequestReview        = "pull_request_review" | ||||
| 	githubEventRegistryPackage          = "registry_package" | ||||
| 	githubEventCreate                   = "create" | ||||
| 	githubEventDelete                   = "delete" | ||||
| 	githubEventFork                     = "fork" | ||||
| 	githubEventPush                     = "push" | ||||
| 	githubEventIssues                   = "issues" | ||||
| 	githubEventIssueComment             = "issue_comment" | ||||
| 	githubEventRelease                  = "release" | ||||
| 	githubEventPullRequestComment       = "pull_request_comment" | ||||
| ) | ||||
|  | ||||
| func convertFromGithubEvent(evt *jobparser.Event) string { | ||||
| 	switch evt.Name { | ||||
| 	case githubEventPullRequest, githubEventPullRequestTarget, githubEventPullRequestReview, | ||||
| 		githubEventPullRequestReviewComment: | ||||
| 		return string(webhook_module.HookEventPullRequest) | ||||
| 	case githubEventRegistryPackage: | ||||
| 		return string(webhook_module.HookEventPackage) | ||||
| 	case githubEventCreate, githubEventDelete, githubEventFork, githubEventPush, | ||||
| 		githubEventIssues, githubEventIssueComment, githubEventRelease, githubEventPullRequestComment: | ||||
| 		fallthrough | ||||
| 	default: | ||||
| 		return evt.Name | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user